summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-20 14:06:53 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-24 17:40:36 +0200
commited86a4f25322ab0d08ad8ee9d3c507146573b1e0 (patch)
tree88a15541206d228aef4aea18ab71189e7ce6d425 /src
parentcc54685b8d0610a682983418bd771e4d6f5f338b (diff)
Don't send QEvent::Hide to an already hidden top level widget
When hiding a popup by clicking outside of its area, a window is closed. Depending on the platform specific implementation details, this can result in multiple calls to QWidgetPrivate::setVisible(false). The first one from the handling of the close event in QWidgetWindow::event; the second from the destruction of the window in QWindow::event. Since the first call already sets the Qt::WA_WState_Hidden flag before calling QWidgetPrivate::hide_helper, we can test if the flag is set and skip the second call if it is. The included test does not reproduce the issue, as that issue only reproduces if the close event is generated by the mouse event handling in the Cocoa platform plugin (which doesn't call QWidget::close, but rather sends a native close event to the platform window). However, it verifies that the fix doesn't introduce any regressions. Change-Id: Id0eda9326a8adf0cc1f6a3840f9ac0b635ab39a1 Fixes: QTBUG-79134 Pick-to: 5.15 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index e4e09c17be..6e3e9e0414 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8102,9 +8102,11 @@ void QWidgetPrivate::setVisible(bool visible)
if (!q->isWindow() && q->parentWidget()) // && !d->getOpaqueRegion().isEmpty())
q->parentWidget()->d_func()->setDirtyOpaqueRegion();
- q->setAttribute(Qt::WA_WState_Hidden);
- if (q->testAttribute(Qt::WA_WState_Created))
- hide_helper();
+ if (!q->testAttribute(Qt::WA_WState_Hidden)) {
+ q->setAttribute(Qt::WA_WState_Hidden);
+ if (q->testAttribute(Qt::WA_WState_Created))
+ hide_helper();
+ }
// invalidate layout similar to updateGeometry()
if (!q->isWindow() && q->parentWidget()) {