diff options
author | Eskil Abrahamsen Blomfeldt <[email protected]> | 2024-12-19 10:26:34 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <[email protected]> | 2024-12-19 16:19:39 +0100 |
commit | f646c1b30bb68d3139dad348155f96cfff444dd7 (patch) | |
tree | d9189e489d1fd6cfdd8e3169b4b5db46d9e33d70 | |
parent | 0f521a0337ba14c90d36abe5a4cea2ba59c58d89 (diff) |
Avoid calling handleScreenRemoved() recursively
In some cases where a nested event loop is run as a result
of a screen being removed (for instance if it's called from
primaryScreenChanged() or similar signals) and multiple
screens were added to the system, then we could end
up calling handleScreenRemoved() for the placeholder screen
recursively. This would cause a crash if anyone actually
used the QScreen pointer passed through the screenRemoved()
signal.
This makes sure we set the placeholder screen to null before
calling handleScreenRemoved() so that we don't call it again
if we happen to end up in the same function in a nested
event loop.
Pick-to: 6.5 6.8 6.9
Change-Id: I237946851ed4dce03fd53093baba102c9686be46
Reviewed-by: David Edmundson <[email protected]>
-rw-r--r-- | src/plugins/platforms/wayland/qwaylanddisplay.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 105877dcfe7..d7a5920afbf 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -621,9 +621,11 @@ void QWaylandDisplay::handleScreenInitialized(QWaylandScreen *screen) mScreens.append(screen); QWindowSystemInterface::handleScreenAdded(screen); if (mPlaceholderScreen) { - QWindowSystemInterface::handleScreenRemoved(mPlaceholderScreen); // handleScreenRemoved deletes the platform screen + QPlatformScreen *s = mPlaceholderScreen; mPlaceholderScreen = nullptr; + QWindowSystemInterface::handleScreenRemoved(s); + } } |