QCocoaScreen: Account for platform window deletion during deliverUpdateRequest
Platform window may be destroyed during update request delivery. For instance, in Qt Quick a user may close a window using some animation with QML ScriptAction. To handle such a situation and prevent a crash due to a dangling pointer, we can simply protect the platformWindow pointer using QPointer. Fixes: QTBUG-128516 Pick-to: 6.7 6.5 Change-Id: I49ecec09d62e184f5df17794b303f147b705e2e3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 2ef1a338a91659871675514921f9a7dc8d1c8805) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
98c1a46a7d
commit
400426c388
@ -421,22 +421,26 @@ void QCocoaScreen::deliverUpdateRequests()
|
||||
auto windows = QGuiApplication::allWindows();
|
||||
for (int i = 0; i < windows.size(); ++i) {
|
||||
QWindow *window = windows.at(i);
|
||||
auto *platformWindow = static_cast<QCocoaWindow*>(window->handle());
|
||||
if (window->screen() != screen())
|
||||
continue;
|
||||
|
||||
QPointer<QCocoaWindow> platformWindow = static_cast<QCocoaWindow*>(window->handle());
|
||||
if (!platformWindow)
|
||||
continue;
|
||||
|
||||
if (!platformWindow->hasPendingUpdateRequest())
|
||||
continue;
|
||||
|
||||
if (window->screen() != screen())
|
||||
continue;
|
||||
|
||||
// Skip windows that are not doing update requests via display link
|
||||
if (!platformWindow->updatesWithDisplayLink())
|
||||
continue;
|
||||
|
||||
platformWindow->deliverUpdateRequest();
|
||||
|
||||
// platform window can be destroyed in deliverUpdateRequest()
|
||||
if (!platformWindow)
|
||||
continue;
|
||||
|
||||
// Another update request was triggered, keep the display link running
|
||||
if (platformWindow->hasPendingUpdateRequest())
|
||||
pauseUpdates = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user