summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2011-01-03 14:08:22 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2011-01-03 15:07:40 (GMT)
commit00cf748fa3d241e52dc0908da90864ea397dab8a (patch)
treed128aa9aa3d7e328d9e7996a4c311f3fc430fad1
parent8ff74f9008b8846624a9da299beb23949af7c249 (diff)
downloadQt-00cf748fa3d241e52dc0908da90864ea397dab8a.zip
Qt-00cf748fa3d241e52dc0908da90864ea397dab8a.tar.gz
Qt-00cf748fa3d241e52dc0908da90864ea397dab8a.tar.bz2
Fix crash when closing QFontDialog::getFont() dialog
Unfortunately, given the large number of ways of showing a QFontDialog, it's possible that we try to close the dialog before its event loop is finished. Setting the Cocoa font panel's isReleaseOnClose property to FALSE ensures the panel is still around when we effectively exit the dialog's event loop. Reviewed-by: Richard Task-number: QTBUG-15666
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 9c63dfa..e2c0ef5 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -116,6 +116,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
- (void)showModelessPanel;
- (void)showWindowModalSheet:(QWidget *)docWidget;
- (void)runApplicationModalPanel;
+- (BOOL)isAppModal;
- (void)changeFont:(id)sender;
- (void)changeAttributes:(id)sender;
- (BOOL)windowShouldClose:(id)window;
@@ -226,6 +227,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
mAppModal = true;
NSWindow *ourPanel = [mStolenContentView window];
+ [ourPanel setReleasedWhenClosed:NO];
[NSApp runModalForWindow:ourPanel];
QAbstractEventDispatcher::instance()->interrupt();
@@ -235,6 +237,11 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
mPriv->fontDialog()->reject();
}
+- (BOOL)isAppModal
+{
+ return mAppModal;
+}
+
- (void)showWindowModalSheet:(QWidget *)docWidget
{
#ifdef QT_MAC_USE_COCOA
@@ -485,6 +492,8 @@ void QFontDialogPrivate::closeCocoaFontPanel()
QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *theDelegate = static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate);
NSWindow *ourPanel = [theDelegate actualPanel];
[ourPanel close];
+ if ([theDelegate isAppModal])
+ [ourPanel release];
[theDelegate cleanUpAfterMyself];
[theDelegate release];
this->delegate = 0;