winrt: Fix crashes for visible window management
First, offscreen windows/surfaces should not be tracked in the visible window list. Secondly when destroying a window, it is not guaranteed that it had been removed first, hence enforce it to guarantee that the visibleWindows list stays correct and does not hold invalid weak pointers to non existing windows. Change-Id: I7027ecd010b8bcb3d05e3f5d460662e883e42e50 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
0f6ace8118
commit
a75cfa60d7
@ -760,7 +760,7 @@ void QWinRTScreen::addWindow(QWindow *window)
|
||||
{
|
||||
Q_D(QWinRTScreen);
|
||||
qCDebug(lcQpaWindows) << __FUNCTION__ << window;
|
||||
if (window == topWindow())
|
||||
if (window == topWindow() || window->surfaceClass() == QSurface::Offscreen)
|
||||
return;
|
||||
|
||||
d->visibleWindows.prepend(window);
|
||||
@ -804,6 +804,8 @@ void QWinRTScreen::lower(QWindow *window)
|
||||
const bool wasTopWindow = window == topWindow();
|
||||
if (wasTopWindow && d->visibleWindows.size() == 1)
|
||||
return;
|
||||
if (window->surfaceClass() == QSurface::Offscreen)
|
||||
return;
|
||||
d->visibleWindows.removeAll(window);
|
||||
d->visibleWindows.append(window);
|
||||
if (wasTopWindow)
|
||||
|
@ -189,6 +189,8 @@ QWinRTWindow::~QWinRTWindow()
|
||||
});
|
||||
RETURN_VOID_IF_FAILED("Failed to completely destroy window resources, likely because the application is shutting down");
|
||||
|
||||
d->screen->removeWindow(window());
|
||||
|
||||
if (!d->surface)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user