Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6.0
-
None
-
CentOS 7.0, Qt-5.6.0, gcc-4.8.3
-
8d45759432e7f954360b76ddeaf2b09acee8606e
Description
I try to run the opengl application without X Window System under platform eglfs and I have segmentation fault when the exiting from it. Then I run qopenglwindow from qtbase examples with the command
./qopenglwindow -platform eglfs.
I have added following code to exit from this app by Escape into the function keyPressEvent:
if (e->key() ==Qt::Key_Escape)
close();
And when I press Esc this application is falling down with segmentation fault! I have run this example under valgrind and I have seen the stack in the attached file stack_close.jpg. Thus the function QEglFSKmsIntegration::destroyNativeWindow (there gbm_surface_destroy is processed) is called before than QOpenGLContext::makeCurrent (and eglMakeCurrent). Therefore the surface pointer is deleted earlier than the working with it is finished.
I have changed close() to qApp->quit() in function keyPressEvent, but the app has falling down too with stack in the attached file stack_quit.jpg. We can see the same as: the pointer is used after it has been deleted.
Then I run the qopenglwidget example, but it is working rightly without segfault.
I've debugged and I've seen that "delete d->platformWindow" is called from the function QWindow::destroy() (which is invoked from the QWindow destructor and from QWindow::closeEvent(QCloseEvent *)) and then the ~QSurface() is called, there QOpenGLContext::doneCurrent() is called. But the event QPlatformSurfaceEvent, that is sent before deleting platformWindow, isn't processed.
I guess this is the problem. In my opinion the attached patch qt-platformSurfaceEvent.patch will solve this problem.