From 8d45759432e7f954360b76ddeaf2b09acee8606e Mon Sep 17 00:00:00 2001 From: Elena Zaretskaya Date: Fri, 8 Apr 2016 12:29:25 +0400 Subject: Fix segfault when exiting app running under eglfs In function QWindow::destroy() the platformWindow is destroyed (QEglFSWindow in this case), but after that the QSurface destructor is called (qsurface.cpp:127), where access to the opengl context is performed (QOpenGLContext::currentContext()->doneCurrent()). Therefore the surface pointer is deleted earlier (gbm_surface_destroy) than the working with it (eglMakeCurrent) is finished. But the event QPlatformSurfaceEvent, that is sent before deleting platformWindow, isn't processed (qwindow.cpp:1665), though we can perform doneCurrent() in the handler of QPlatformSurfaceEvent. The full description with valgrind stacks on bugreports. Task-number: QTBUG-52399 Change-Id: I69035dfd8ba5b5eeec243bc0edd3f571dc9525f9 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qwindow.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 68bcbdec71..7f84706b6f 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2109,6 +2109,17 @@ bool QWindow::event(QEvent *ev) break; } + case QEvent::PlatformSurface: { + if ((static_cast(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) { +#ifndef QT_NO_OPENGL + QOpenGLContext *context = QOpenGLContext::currentContext(); + if (context && context->surface() == static_cast(this)) + context->doneCurrent(); +#endif + } + break; + } + default: return QObject::event(ev); } -- cgit v1.2.3