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

Crash using shared QOpenGLTexture

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.11.3
    • GUI: OpenGL
    • None
    • Linux/X11

    Description

      Let's say I'm doing OpenGL stuff in a QOpenGLWidget that belongs to a QDockWidget. Docking and undocking causes the QOpenGLWidget to get a new context.

      Because I don't want to have to recreate (and clean up) all my GL resources every time the widget's context gets recreated, I am using global context sharing. This works well for buffers and shaders, but causes QOpenGLTexture to crash, even though the underlying GL resource is AFAIK still usable.

      The crash occurs because each QOpenGLContext has a unique copy of QOpenGLFunctions. QOpenGLBuffer and QOpenGLShaderProgram, where they need the functions, just use the current context. However, QOpenGLTexture retains the pointer of the instance belonging to the context with which it was created. Attempts to use the QOpenGLTexture after the context has been recreated thus attempt to access an object that no longer exists.

      This feels like a bug. Although the uniqueness of QOpenGLFunctions is itself potentially questionable, and sharing which would be owned by the sharing context is likely a plausible solution, it may be preferable for QOpenGLContext to simply not retain the pointer at all, and instead use the current context as other Qt GL-resource wrapping classes do. (The latter is both almost certainly easier to implement, and seems less likely to crash even when misused, or at worst more likely to crash trying to dereference a null pointer as opposed to a "dead" pointer.)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              lagocs Laszlo Agocs
              matthew.woehlke Matthew Woehlke
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes