QWidget: Store initialScreen as QPointer

A Toplevel QWidget can hold a pointer to the screen where it will
eventually show contents, before a QWidgetWindow is created which then
takes precedence.

The screen member of QWindows is always kept up-to-date when a screen is
removed, but not the contents of a toplevel window. If a widget has
setScreen called but is never shown, it has potentially dangling pointer
which can cause issues in the future.

Pick-to: 6.7 6.5
Change-Id: Ia7c80549e8b3c90a75cdde745487e87ecddaca63
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d67acf94afffde6a71498be6e30447f3acf7558e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
David Edmundson 2024-07-31 11:59:14 +01:00 committed by Qt Cherry-pick Bot
parent 5c94c5a4ef
commit 6af4e5f604

View File

@ -109,7 +109,7 @@ struct QTLWExtra {
QRect frameStrut;
QRect normalGeometry; // used by showMin/maximized/FullScreen
Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
QScreen *initialScreen; // Screen when passing a QDesktop[Screen]Widget as parent.
QPointer<QScreen> initialScreen; // Screen when passing a QDesktop[Screen]Widget as parent.
std::vector<std::unique_ptr<QPlatformTextureList>> widgetTextures;