Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109171

QOpenGLWidget inside QDockWidget produces segfault on undocking.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.7, 6.4.1
    • GUI: OpenGL
    • None
    • Manjaro Linux, Nvidia RTX 3060
    • Linux/X11
    • 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.

      Attachments

        For Gerrit Dashboard: QTBUG-109171
        # Subject Branch Project Status CR V

        Activity

          People

            lagocs Laszlo Agocs
            skarndev skarndev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes