diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 12 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 12 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 777c3d65b6..b58f58caeb 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -182,7 +182,17 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); mDialogIsExecuting = false; mResultSet = false; mClosingDueToKnownButton = false; - [mColorPanel makeKeyAndOrderFront:mColorPanel]; + // Make this an asynchronous call, so the panel is made key only + // in the next event loop run. This is to make sure that by + // the time the modal loop is run in runModalForWindow below, + // which internally also sets the panel to key window, + // the panel is not yet key, and the NSApp still has the right + // reference to the _previousKeyWindow. Otherwise both NSApp.key + // and NSApp._previousKeyWindow would wrongly point to the panel, + // loosing any reference to the window that was key before. + dispatch_async(dispatch_get_main_queue(), ^{ + [mColorPanel makeKeyAndOrderFront:mColorPanel]; + }); } - (BOOL)runApplicationModalPanel diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index ac5d784b79..5cdf6bf02c 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -166,7 +166,17 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); { mDialogIsExecuting = false; mResultSet = false; - [mFontPanel makeKeyAndOrderFront:mFontPanel]; + // Make this an asynchronous call, so the panel is made key only + // in the next event loop run. This is to make sure that by + // the time the modal loop is run in runModalForWindow below, + // which internally also sets the panel to key window, + // the panel is not yet key, and the NSApp still has the right + // reference to the _previousKeyWindow. Otherwise both NSApp.key + // and NSApp._previousKeyWindow would wrongly point to the panel, + // loosing any reference to the window that was key before. + dispatch_async(dispatch_get_main_queue(), ^{ + [mFontPanel makeKeyAndOrderFront:mFontPanel]; + }); } - (BOOL)runApplicationModalPanel |