summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-03-02 14:08:55 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-03-05 14:17:49 (GMT)
commitf3ecbb007acf39b43c73be26f4cbbf195c352e57 (patch)
treeb83124052fde484bbdbff941773d64468a20308b
parent0cb155516992d3bb917f72bdab9f28b9e65ff40d (diff)
downloadQt-f3ecbb007acf39b43c73be26f4cbbf195c352e57.zip
Qt-f3ecbb007acf39b43c73be26f4cbbf195c352e57.tar.gz
Qt-f3ecbb007acf39b43c73be26f4cbbf195c352e57.tar.bz2
Mac: QFontDialog will not sometimes leave modality
It turns out the the code implemented two different ways of entering modality, and mixed the two when it came to exit modality. This patch just uses the nsapp runmodalforwindow approach. Reviewed-by: cduclos
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 93410e7..3a4c688 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -95,7 +95,6 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
BOOL mPanelHackedWithButtons;
CGFloat mDialogExtraWidth;
CGFloat mDialogExtraHeight;
- NSModalSession mModalSession;
}
- (id)initWithFontPanel:(NSFontPanel *)panel
stolenContentView:(NSView *)stolenContentView
@@ -106,7 +105,6 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
extraHeight:(CGFloat)extraHeight;
- (void)changeFont:(id)sender;
- (void)changeAttributes:(id)sender;
-- (void)setModalSession:(NSModalSession)session;
- (BOOL)windowShouldClose:(id)window;
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
- (void)relayout;
@@ -163,7 +161,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
mPanelHackedWithButtons = (okButton != 0);
mDialogExtraWidth = extraWidth;
mDialogExtraHeight = extraHeight;
- mModalSession = 0;
if (mPanelHackedWithButtons) {
[self relayout];
@@ -216,12 +213,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
mPriv->updateSampleFont(*mQtFont);
}
-- (void)setModalSession:(NSModalSession)session
-{
- Q_ASSERT(!mModalSession);
- mModalSession = session;
-}
-
- (BOOL)windowShouldClose:(id)window
{
Q_UNUSED(window);
@@ -368,21 +359,14 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
- (void)finishOffWithCode:(NSInteger)code
{
- if (mPriv) {
- if (mModalSession) {
- [NSApp endModalSession:mModalSession];
- mModalSession = 0;
- }
- // Hack alert!
- // Since this code path was never intended to be followed when starting from exec
- // we need to force the dialog to communicate the new font, otherwise the signal
- // won't get emitted.
- if(code == NSOKButton)
- mPriv->sampleEdit->setFont([self qtFont]);
- mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
- } else {
- [NSApp stopModalWithCode:code];
- }
+ [NSApp stopModalWithCode:code];
+ // Hack alert!
+ // Since this code path was never intended to be followed when starting from exec
+ // we need to force the dialog to communicate the new font, otherwise the signal
+ // won't get emitted.
+ if(code == NSOKButton)
+ mPriv->sampleEdit->setFont([self qtFont]);
+ mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
}
- (void)cleanUpAfterMyself
@@ -544,8 +528,6 @@ void *QFontDialogPrivate::_q_constructNativePanel()
}
NSString *title = @"Select font";
[ourPanel setTitle:title];
-
- [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
return delegate;
}
@@ -575,6 +557,7 @@ void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
NSWindow *ourPanel = [delegate actualPanel];
[ourPanel retain];
+
int rval = [NSApp runModalForWindow:ourPanel];
QAbstractEventDispatcher::instance()->interrupt();
[ourPanel release];