Skip to content

Commit

Permalink
Set QGuiApplicationPrivate variables after platform window is destroyed
Browse files Browse the repository at this point in the history
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ø <[email protected]>
  • Loading branch information
AndyShawQt committed Apr 8, 2021
1 parent f27b914 commit f64201c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/gui/kernel/qwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit f64201c

Please sign in to comment.