summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2021-10-13 13:35:10 +0200
committerDoris Verria <doris.verria@qt.io>2021-10-14 10:19:29 +0200
commitec09900997e9b92206938ca5f9fe2e356440e513 (patch)
tree0014d2b5b852cb4d8f93b85878d5fe3f9682b24a /src/widgets/kernel/qwidget.cpp
parentdcb281af7dc1a41813300ea74f1890902f6bf748 (diff)
Call QWidget close handling in QWidget::close for non-toplevel native widgets
Since commit 7ba75d0 we close the QWindow in QWidget::close for native widgets and trigger the closeEvent in QWidgetWindow. However, if the widget's window handle is not a top level window, QWindow::close() will not close the window, failing in this way to deliver the closeEvent and call the close handling in QWidgetPrivate::handleClose. To fix, call handleClose() from QWidget::close for such widgets. Task-number: QTBUG-74606 Pick-to: 6.2 Change-Id: Ied342eced3340aaf19b5443762935b1a5fc5c27b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 5c42a5da23..2534a7aeba 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8466,8 +8466,10 @@ bool QWidgetPrivate::close()
// Close native widgets via QWindow::close() in order to run QWindow
// close code. The QWidget-specific close code in handleClose() will
// in this case be called from the Close event handler in QWidgetWindow.
- if (QWindow *widgetWindow = windowHandle())
- return widgetWindow->close();
+ if (QWindow *widgetWindow = windowHandle()) {
+ if (widgetWindow->isTopLevel())
+ return widgetWindow->close();
+ }
return handleClose(QWidgetPrivate::CloseWithEvent);
}