diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-03-05 09:11:12 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-03-05 14:17:50 (GMT) |
commit | f84112bb06e9a7a65afe9ba20d3419b33aee1e5d (patch) | |
tree | 27e980fc4c5356ddd1fbf5f32c637207bf992811 /src/gui/dialogs/qfontdialog_mac.mm | |
parent | 0e9bd62d905db6e0015a58609a747bb22521f8cc (diff) | |
download | Qt-f84112bb06e9a7a65afe9ba20d3419b33aee1e5d.zip Qt-f84112bb06e9a7a65afe9ba20d3419b33aee1e5d.tar.gz Qt-f84112bb06e9a7a65afe9ba20d3419b33aee1e5d.tar.bz2 |
Mac: qfontdialog autotest failes
The reason is the way we leave modality in the font dialog. When we
do, we need to close the non-native qfontdialog as well, but doing
so will issue callbacks (like set_visible_sys(false)), that will
cause problems. This patch makes sure we wait with such callbacks
until the native modal event loop has finished executing
Reviewed-by: cduclos
Diffstat (limited to 'src/gui/dialogs/qfontdialog_mac.mm')
-rw-r--r-- | src/gui/dialogs/qfontdialog_mac.mm | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index c6653cb..919790b 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -103,6 +103,8 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin BOOL mPanelHackedWithButtons; CGFloat mDialogExtraWidth; CGFloat mDialogExtraHeight; + int mReturnCode; + BOOL mAppModal; } - (id)initWithFontPanel:(NSFontPanel *)panel stolenContentView:(NSView *)stolenContentView @@ -172,6 +174,8 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) mPanelHackedWithButtons = (okButton != 0); mDialogExtraWidth = extraWidth; mDialogExtraHeight = extraHeight; + mReturnCode = -1; + mAppModal = false; if (mPanelHackedWithButtons) { [self relayout]; @@ -208,6 +212,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) - (void)showModelessPanel { + mAppModal = false; NSWindow *ourPanel = [mStolenContentView window]; [ourPanel makeKeyAndOrderFront:self]; } @@ -215,24 +220,37 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) - (void)runApplicationModalPanel { QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); + mAppModal = true; NSWindow *ourPanel = [mStolenContentView window]; [NSApp runModalForWindow:ourPanel]; QAbstractEventDispatcher::instance()->interrupt(); + + if (mReturnCode == NSOKButton) + mPriv->fontDialog()->accept(); + else + mPriv->fontDialog()->reject(); } - (void)showWindowModalSheet:(QWidget *)docWidget { #ifdef QT_MAC_USE_COCOA - Q_UNUSED(docWidget); + NSWindow *window = qt_mac_window_for(docWidget); +#else + WindowRef hiwindowRef = qt_mac_window_for(docWidget); + NSWindow *window = [[NSWindow alloc] initWithWindowRef:hiwindowRef]; + CFRetain(hiwindowRef); +#endif + + mAppModal = false; NSWindow *ourPanel = [mStolenContentView window]; [NSApp beginSheet:ourPanel - modalForWindow:qt_mac_window_for(docWidget) + modalForWindow:window modalDelegate:0 didEndSelector:0 contextInfo:0 ]; -#else - Q_UNUSED(docWidget); - [self showModelessPanel]; + +#ifndef QT_MAC_USE_COCOA + CFRelease(hiwindowRef); #endif } @@ -420,12 +438,18 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) } #endif - [NSApp stopModalWithCode:code]; if(code == NSOKButton) mPriv->sampleEdit->setFont([self qtFont]); - QMetaObject::invokeMethod(mPriv->fontDialog(), - (code == NSOKButton) ? "accept" : "reject", - Qt::QueuedConnection); + + if (mAppModal) { + mReturnCode = code; + [NSApp stopModalWithCode:code]; + } else { + if (code == NSOKButton) + mPriv->fontDialog()->accept(); + else + mPriv->fontDialog()->reject(); + } } - (void)cleanUpAfterMyself |