EGLFS: Fix plugin destruction

The proper init/destruction order is as follows:

QEglFsHooks::platformInit()
eglInitialize()
eglTerminate()
QEglFsHooks::platformDestroy()

Prior to this patch platformDestroy() was called before eglTerminate(),
leading to a crash on some platforms.

Additionally we need to destroy the native windows before deleting the
screen, otherwise the QEglFSWindow destructor ends up calling into the
deallocated screen.

Change-Id: Id08ccbac9bb44a778bcf1a55f73c0057e0a7b3af
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
bb10
Louai Al-Khanji 2014-09-19 12:39:02 +03:00
parent bd09405792
commit 9618fb7262
4 changed files with 18 additions and 6 deletions

View File

@ -95,9 +95,15 @@ QEGLPlatformIntegration::QEGLPlatformIntegration()
QEGLPlatformIntegration::~QEGLPlatformIntegration()
{
foreach (QWindow *w, qGuiApp->topLevelWindows())
w->destroy();
delete m_screen;
if (m_display != EGL_NO_DISPLAY)
eglTerminate(m_display);
destroy();
}
void QEGLPlatformIntegration::initialize()
@ -118,6 +124,11 @@ void QEGLPlatformIntegration::initialize()
m_vtHandler.reset(new QFbVtHandler);
}
void QEGLPlatformIntegration::destroy()
{
}
QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const
{
return createUnixEventDispatcher();

View File

@ -65,6 +65,7 @@ public:
~QEGLPlatformIntegration();
void initialize() Q_DECL_OVERRIDE;
virtual void destroy();
QEGLPlatformScreen *screen() const { return m_screen; }
EGLDisplay display() const { return m_display; }

View File

@ -67,11 +67,6 @@ QEglFSIntegration::QEglFSIntegration()
initResources();
}
QEglFSIntegration::~QEglFSIntegration()
{
QEglFSHooks::hooks()->platformDestroy();
}
bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
// We assume that devices will have more and not less capabilities
@ -91,6 +86,11 @@ void QEglFSIntegration::initialize()
createInputHandlers();
}
void QEglFSIntegration::destroy()
{
QEglFSHooks::hooks()->platformDestroy();
}
EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
{
return QEglFSHooks::hooks()->platformDisplay();

View File

@ -44,9 +44,9 @@ class QEglFSIntegration : public QEGLPlatformIntegration
{
public:
QEglFSIntegration();
~QEglFSIntegration();
void initialize() Q_DECL_OVERRIDE;
void destroy() Q_DECL_OVERRIDE;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE;