From ea1af6b7ed972910c6e125f9946f1f03f7b0de45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 30 May 2023 18:01:19 +0200 Subject: Only consider QScreen virtual siblings that have been added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a platform builds up a list of QPlatformScreens, and then adds them incrementally, while at the same time implementing virtualSiblings in QPlatformScreen to return the full list of screens, the virtual sibling QScreens will contain nullptrs for each non-added screen. It could be argued that this is the fault of the platform plugin, since it's reporting a virtual sibling that it hasn't added yet, but we can easily work around it in QScreen as well. Fixes: QTBUG-113977 Pick-to: 6.5 Change-Id: I4b9472646a5cc10b6fd35c606e3ae15941da1587 Reviewed-by: Thiago Macieira Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qscreen.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index abf8c4569c..d598e4fc54 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -360,8 +360,11 @@ QList QScreen::virtualSiblings() const const QList platformScreens = d->platformScreen->virtualSiblings(); QList screens; screens.reserve(platformScreens.size()); - for (QPlatformScreen *platformScreen : platformScreens) - screens << platformScreen->screen(); + for (QPlatformScreen *platformScreen : platformScreens) { + // Only consider platform screens that have been added + if (auto *knownScreen = platformScreen->screen()) + screens << knownScreen; + } return screens; } -- cgit v1.2.3