Bug 404874

Summary: KFileWidget: preview causes widget duplication on Mac
Product: [Frameworks and Libraries] frameworks-kio Reporter: RJVB <rjvbertin>
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: major CC: kde, kdelibs-bugs
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot showing the described issue

Description RJVB 2019-02-27 17:14:32 UTC
Created attachment 118402 [details]
Screenshot showing the described issue

SUMMARY
Activating the embedded preview in the KFileWidget causes a duplication of the entire KFileWidget (but not the surrounding dialog), which may cause a crash (deep in the cocoa platform QPA, on exit or when the dialog is destroyed; under the QSplitter dtor to be more precise).
The duplicate widget appears under the dialog, and becomes the widget to interact with although the toolbar remains usable (and linked) in both widgets.

STEPS TO REPRODUCE
1. Start kfilewidgettest_gui.app/Contents/MacOS/kfilewidgettest_gui from the KIO tests
2. enable preview mode if not already enabled
3. navigate and move the dialog around.

OBSERVED RESULT
The duplicate widget opens and the original KFileWidget becomes mostly a ghost. The toolbar will float on top of the original dialog and its contents; the rest remains on a lower level.

EXPECTED RESULT
Behaviour as under X11.
This is also what happens when Qt is built for X11 or when using the xcb QPA with an otherwise Cocoa build, which suggests that the preview mode does something that is not properly cross-platform.

SOFTWARE/OS VERSIONS
Mac OS X: 10.9.5 
KDE Frameworks Version: 5.52.0 ; KIO is built from a more recent master branch checkout.
Qt Version: 5.9.7

ADDITIONAL INFORMATION
This happens both with my osx-integration QPT and without it. The screenshot was made after disabling that plugin, = in stock cocoa mode.
Comment 1 Kai Uwe Broulik 2019-02-28 09:02:34 UTC
This looks eerily similar to QTBUG-59017, maybe it's a similar root cause (check the comments in that bug report for what's going on)
Comment 2 RJVB 2019-02-28 09:19:30 UTC
https://bugreports.qt.io/browse/QTBUG-48130 , calling winId() or otherwise turning a window native?

That would mean that I might not get the issue if I start the test app with the env. variable that forces Qt to use native windows all the time (or, the KFileWidget gets duplicated all the time).

(I hope the KP I got yesterday wasn't due to me tinkering with this ... or maybe I should hope that it is...)