diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2014-02-06 17:34:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-06 20:50:05 +0100 |
commit | 42aa8aa8c2fb06cb98fb1c924976095b67a70a62 (patch) | |
tree | 864322ed0b7649d64bdd83f0464bc241489e320e | |
parent | 577909b59a52c7d2755d2ce439895641ca93c4ad (diff) |
Cocoa: Handle gracefully closing a window without event dispatcher
Task-number: QTBUG-36696
Change-Id: I799eb351ee8ac1529cfbf009df3e7d57ec3a24ea
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8becfb1cc2..d13c6a8a3f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -528,11 +528,13 @@ void QCocoaWindow::setVisible(bool visible) if (m_glContext) m_glContext->windowWasHidden(); QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); - Q_ASSERT(cocoaEventDispatcher != 0); - QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); + QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0; + if (cocoaEventDispatcher) + cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); if (m_nsWindow) { if (m_hasModalSession) { - cocoaEventDispatcherPrivate->endModalSession(window()); + if (cocoaEventDispatcherPrivate) + cocoaEventDispatcherPrivate->endModalSession(window()); m_hasModalSession = false; } else { if ([m_nsWindow isSheet]) @@ -540,7 +542,8 @@ void QCocoaWindow::setVisible(bool visible) } hide(); - if (m_nsWindow == [NSApp keyWindow] && !cocoaEventDispatcherPrivate->currentModalSession()) { + if (m_nsWindow == [NSApp keyWindow] + && !(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) { // Probably because we call runModalSession: outside [NSApp run] in QCocoaEventDispatcher // (e.g., when show()-ing a modal QDialog instead of exec()-ing it), it can happen that // the current NSWindow is still key after being ordered out. Then, after checking we |