Bug 483757

Summary: KFileWidget creation quits QApplication
Product: [Frameworks and Libraries] frameworks-kio Reporter: wolf.seifert
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: kdelibs-bugs, nicolas.fella
Priority: NOR Keywords: qt6
Version: 6.0.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Reproducer: kfilewidget.cpp and qfiledialog.cpp + CMakeLists.txt

Description wolf.seifert 2024-03-16 12:38:55 UTC
Created attachment 167323 [details]
Reproducer: kfilewidget.cpp and qfiledialog.cpp + CMakeLists.txt

SUMMARY
***
After creation of a KFileWidget the QApplication will be closed (i.e. QApplication::exec() will entered and left again). The same happens for QFileDialog if native dialogs are used. When qt dialogs are used the program stays in QApplication::exec()  (for further event processing).
***

STEPS TO REPRODUCE
1. Unzip the attached kdefiledialog.zip
2. Build with cmake
3. Run the program

OBSERVED RESULT
The program exits.

EXPECTED RESULT
The program should keep on running.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Graphic Platform: Wayland
Comment 1 Antonio Rojas 2024-03-16 16:17:49 UTC

*** This bug has been marked as a duplicate of bug 483439 ***
Comment 2 Nicolas Fella 2024-03-17 00:47:24 UTC
Your program terminates because it has no windows of its own, so when the last QEventLoopLocker goes away the event loop exits. KFileWidget internally uses QEventLoopLocker, so creating it triggers this behavior.

Use QApplication::setQuitLockEnabled(false) to prevent this.
Comment 3 wolf.seifert 2024-03-17 05:23:48 UTC
Thanks!