diff options
author | Doris Verria <doris.verria@qt.io> | 2021-09-07 15:26:30 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-07 18:56:21 +0000 |
commit | f1244e54e5843c48d01efc1e06481d16cf3e2c82 (patch) | |
tree | b8593456a7d7a85ab6167cc06cf08e0576dca3ea /src/plugins | |
parent | ba5d797d0787276019b342fdb5b2dfb72ea6c550 (diff) |
Cocoa: Make sure we can display multiple sheets for the same NSWindow
On macOS, to display a modal with Qt::WindowModality set, or of type
Qt::Sheet, we call beginSheet:completinHandler:. However, this method
won't display the specified sheet unless the current active one is
dismissed, which is a different behavior than what we expect for
this case. Use beginCriticalSheet:completionHandler: whenever we
already have an active sheet attached to the NSWindow, which allows
us to display multiple sheets for the same window.
Fixes: QTBUG-91059
Change-Id: I86bdbcbd63758edbbc48a8aade0178917dcb0e5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit f3bc1f850046341745d42e2d6739724321634891)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6e7fc5cdbb..09b848892a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -368,7 +368,11 @@ void QCocoaWindow::setVisible(bool visible) if (window()->windowState() != Qt::WindowMinimized) { if (parentCocoaWindow && (window()->modality() == Qt::WindowModal || window()->type() == Qt::Sheet)) { // Show the window as a sheet - [parentCocoaWindow->nativeWindow() beginSheet:m_view.window completionHandler:nil]; + NSWindow *nativeParentWindow = parentCocoaWindow->nativeWindow(); + if (!nativeParentWindow.attachedSheet) + [nativeParentWindow beginSheet:m_view.window completionHandler:nil]; + else + [nativeParentWindow beginCriticalSheet:m_view.window completionHandler:nil]; } else if (window()->modality() == Qt::ApplicationModal) { // Show the window as application modal eventDispatcher()->beginModalSession(window()); |