eglfs: Call destroy() from dtors of concrete windows

Calling destroy from the QEglFSWindow dtor() triggers the virtual
invalidateSurface() to be called on a partly destroyed object. As the
child windows deregister themselves from their screens on
invalidateSurface() this is dangerous: It leaves a dangling pointer in
the screen.

Fixes: QTBUG-75075
Change-Id: Idd3fea18562d41973f364340df875a50dbd5691e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Ulf Hermann 2019-04-15 15:50:15 +02:00
parent 5b3dfa470e
commit 7c6b969383
4 changed files with 11 additions and 0 deletions

View File

@ -167,6 +167,9 @@ void QEglFSWindow::create()
void QEglFSWindow::destroy()
{
if (!m_flags.testFlag(Created))
return; // already destroyed
#ifndef QT_NO_OPENGL
QOpenGLCompositor::instance()->removeWindow(this);
#endif

View File

@ -55,6 +55,9 @@ public:
: QEglFSWindow(w),
m_integration(integration)
{ }
~QEglFSKmsGbmWindow() { destroy(); }
void resetSurface() override;
void invalidateSurface() override;

View File

@ -116,6 +116,8 @@ public:
, m_egl_stream(EGL_NO_STREAM_KHR)
{ }
~QEglFSKmsEglDeviceWindow() { destroy(); }
void invalidateSurface() override;
void resetSurface() override;

View File

@ -205,6 +205,9 @@ public:
: QEglFSWindow(w)
, m_integration(integration)
{}
~QEglFSKmsVsp2Window() { destroy(); }
void resetSurface() override;
void invalidateSurface() override;
const QEglFSKmsVsp2Integration *m_integration;