diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 12:28:07 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 13:03:39 +0200 |
commit | 8524d29ce8aa16c65abd8eb6688ce24b710fe356 (patch) | |
tree | f04ff72fca3204b1aac996f51a749d94445f4586 /src/gui/kernel | |
parent | 06d431e37f1015b91d0a6a7d9d6680f133e32c57 (diff) |
Prevent asserts in certain QWindow re-creation cases
Amends 402efef57bb6a04ad778d3139100becc2cba31eb. The original patch
has a problem, namely that it directly calls QPlatformWindow::requestUpdate()
instead of going through QWindow::requestUpdate(). As there is a chance that
an update gets scheduled between the creation of the QPlatformWindow and this
extra, optional invocation of requestUpdate() at the end of QWindow::create(),
this becomes quite unsafe because QPlatformWindow, unlike QWindow, is not
graceful: it will just assert if there is a pending update still.
Solve the whole thing by storing the updateRequestPending flag of QWindowPrivate,
then resetting it, and then going through the safe, public
QWindow::requestUpdate() when our copy of the flag says so.
Task-number: QTBUG-81400
Task-number: QTBUG-70957
Pick-to: 5.15
Change-Id: I99aedfae3928b75301b46a4666c169e657ff8079
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 702c055fbb..fd89e479b8 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -515,6 +515,11 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) if (platformWindow) return; + // avoid losing update requests when re-creating + const bool needsUpdate = updateRequestPending; + // the platformWindow, if there was one, is now gone, so make this flag reflect reality now + updateRequestPending = false; + if (q->parent()) q->parent()->create(); @@ -553,8 +558,8 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); QGuiApplication::sendEvent(q, &e); - if (updateRequestPending) - platformWindow->requestUpdate(); + if (needsUpdate) + q->requestUpdate(); } void QWindowPrivate::clearFocusObject() |