Prevent asserts in certain QWindow re-creation cases
Amends 402efef57b. 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>
bb10
parent
06d431e37f
commit
8524d29ce8
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue