Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.7, 6.4.1
-
None
-
Manjaro Linux, Nvidia RTX 3060
-
-
3bad6d597 (dev), 6385e154d (6.5)
Description
When QOpenGLWidget is made a child of QDockWidget, undocking a QDockWidget leads to the loss and destruction of QOpenGLWidget's QOpenGLContext, as a new native window for the undocked QDockWidget is created.
The QOpenGLContext succesfully emits the aboutToBeDestroyed() signal. Later, when the window is already undocked, QOpenGLContext for the QOpenGLWidget is recreated automatically. isValid() call on it reports true, and it is made current in initializeGL() and paintGL() of the QOpenGLWidget. However, accessing versionFunctions<QOpenGLFunctions_4_5_Core> or the Qt 6 factory equivalent on it produces an object in an incorrect state. Only calls relevant to 1.1 OpenGL work there, while others (for example glDrawArrays) produce a segfault crash.
Calling create() manually on that context, as stated in the Qt docs on how to handle the context loss, does not help. The newly created context keeps producing corrupted function wrappers. The only workaround I found is to recreate the QOpenGLWidget itself. In this case, the context is created correctly.
The behavior is very consistent on Linux. If you are not able to reproduce, I can provide an MRE project, but generally just undocking any running QOpenGLWidget is enough.