summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-10-22 13:01:38 +0200
committerAndy Shaw <andy.shaw@qt.io>2019-10-29 10:45:19 +0200
commitccd3bf0871b81dfc09bb469b161f32dfb47ee53e (patch)
tree13fd6e178bc30c35ec612e04ce7ee2bcfcf3080c /src
parentd86192e5ba7911407881f5079c4486c1fb084dc6 (diff)
Ensure that child windows are visible again when showing their parent
When a window is closed, then it will cause the child windows to be closed as well as a result. Therefore in order to ensure that they are shown again as a result, we need to remove the WA_WState_ExplicitShowHide attribute if the widget was not already hidden before. This enables us to test for this attribute when calling showChildren(), so that if the window has a windowHandle then we can make sure that this widget is shown again. Fixes: QTBUG-73021 Change-Id: I1186242b889899dfcd38d782a67567348e2055ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp4
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp12
2 files changed, 13 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 0fa5907744..048a17364b 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
@@ -8460,6 +8460,8 @@ void QWidgetPrivate::showChildren(bool spontaneous)
QList<QObject*> childList = children;
for (int i = 0; i < childList.size(); ++i) {
QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
+ if (widget && widget->windowHandle() && !widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
+ widget->setAttribute(Qt::WA_WState_Hidden, false);
if (!widget
|| widget->isWindow()
|| widget->testAttribute(Qt::WA_WState_Hidden))
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index aad505ed29..878e484ab8 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -72,10 +72,18 @@ public:
void setVisible(bool visible) override
{
Q_Q(QWidgetWindow);
- if (QWidget *widget = q->widget())
+ if (QWidget *widget = q->widget()) {
+ // Check if the widget was already hidden, as this indicates it was done
+ // explicitly and not because the parent window in this case made it hidden.
+ // In which case do not automatically show the widget when the parent
+ // window is shown.
+ const bool wasHidden = widget->testAttribute(Qt::WA_WState_Hidden);
QWidgetPrivate::get(widget)->setVisible(visible);
- else
+ if (!wasHidden)
+ widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false);
+ } else {
QWindowPrivate::setVisible(visible);
+ }
}
QWindow *eventReceiver() override {