summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qwindow.cpp1
-rw-r--r--src/gui/kernel/qwindow_p.h1
-rw-r--r--src/widgets/kernel/qwidget.cpp25
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp4
4 files changed, 30 insertions, 1 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 7f6e5044cb..845627756e 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2254,6 +2254,7 @@ bool QWindow::close()
if (!d->platformWindow)
return true;
+ QBoolBlocker inCloseReset(d->inClose);
return d->platformWindow->close();
}
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 5d9de82295..82d4bd430c 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -136,6 +136,7 @@ public:
bool visible= false;
bool visibilityOnDestroy = false;
bool exposed = false;
+ bool inClose = false;
QSurfaceFormat requestedFormat;
QString windowTitle;
QString windowFilePath;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 61a8605d22..c96b422b14 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8360,6 +8360,24 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
}
}
+/*!
+ \internal
+
+ For windows, this is called from the QWidgetWindow::handleCloseEvent implementation,
+ which QWidget::close indirectly calls by closing the QWindow. \a mode will be
+ CloseWithEvent if QWidgetWindow::handleCloseEvent is called indirectly by
+ QWindow::close, and CloseWithSpontaneousEvent if the close event originates from the
+ system (i.e. the user clicked the close button in the title bar).
+
+ QDialog calls this method directly in its hide() implementation, which might be
+ called from the QDialog::closeEvent override. \a mode will be set to CloseNoEvent
+ to prevent recursion.
+
+ For non-windows, this is called directly by QWidget::close, and \a mode will be
+ CloseWithEvent.
+
+ The function is also called by the QWidget destructor, with \a mode set to CloseNoEvent.
+*/
bool QWidgetPrivate::close_helper(CloseMode mode)
{
if (data.is_closing)
@@ -8384,6 +8402,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
}
}
+ // even for windows, make sure we deliver a hide event and that all children get hidden
if (!that.isNull() && !q->isHidden())
q->hide();
@@ -8446,6 +8465,12 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
bool QWidget::close()
{
+ // Close native widgets via QWindow::close() in order to run QWindow
+ // close code. The QWidget-specific close code in close_helper() will
+ // in this case be called from the Close event handler in QWidgetWindow.
+ if (QWindow *widgetWindow = windowHandle())
+ return widgetWindow->close();
+
return d_func()->close_helper(QWidgetPrivate::CloseWithEvent);
}
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 346289cafe..029d152f5d 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -840,7 +840,9 @@ void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
void QWidgetWindow::handleCloseEvent(QCloseEvent *event)
{
- bool is_closing = m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
+ Q_D(QWidgetWindow);
+ bool is_closing = m_widget->d_func()->close_helper(d->inClose ? QWidgetPrivate::CloseWithEvent
+ : QWidgetPrivate::CloseWithSpontaneousEvent);
event->setAccepted(is_closing);
}