Set QGuiApplicationPrivate variables after platform window is destroyed

By setting these variables after the platform window has been destroyed,
it will enable any platform specific code to handle changes in terms of
focus and so on before the destruction of the window changes these
directly. For example, this will prevent a problem with iOS where it
keeps track of the current focus object as the signal indicating that
the change to focus will still be emitted. This is before the variable
is set to nullptr if there is no parent window.

Change-Id: Ie540c10760d06dc62e163ccf6f6edea200b43bbf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Andy Shaw 2021-03-29 12:48:16 +02:00
parent f27b914e79
commit f64201c493

View File

@ -1972,17 +1972,6 @@ void QWindowPrivate::destroy()
}
}
if (QGuiApplicationPrivate::focus_window == q)
QGuiApplicationPrivate::focus_window = q->parent();
if (QGuiApplicationPrivate::currentMouseWindow == q)
QGuiApplicationPrivate::currentMouseWindow = q->parent();
if (QGuiApplicationPrivate::currentMousePressWindow == q)
QGuiApplicationPrivate::currentMousePressWindow = q->parent();
for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i)
if (QGuiApplicationPrivate::tabletDevicePoints.at(i).target == q)
QGuiApplicationPrivate::tabletDevicePoints[i].target = q->parent();
bool wasVisible = q->isVisible();
visibilityOnDestroy = wasVisible && platformWindow;
@ -2007,6 +1996,17 @@ void QWindowPrivate::destroy()
platformWindow = nullptr;
delete pw;
if (QGuiApplicationPrivate::focus_window == q)
QGuiApplicationPrivate::focus_window = q->parent();
if (QGuiApplicationPrivate::currentMouseWindow == q)
QGuiApplicationPrivate::currentMouseWindow = q->parent();
if (QGuiApplicationPrivate::currentMousePressWindow == q)
QGuiApplicationPrivate::currentMousePressWindow = q->parent();
for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i)
if (QGuiApplicationPrivate::tabletDevicePoints.at(i).target == q)
QGuiApplicationPrivate::tabletDevicePoints[i].target = q->parent();
resizeEventPending = true;
receivedExpose = false;
exposed = false;