Important: Please read the Qt Code of Conduct -

QOpenGLFunctions_3_3_Core Incorrectly Assumes it Has Been Initialized

  • I've got a Widget derived from QOpenGLWidget and QOpenGLFunctions_3_3_Core

     class MyWidget : public QOpenGLWidget, 
                         protected QOpenGLFunctions_3_3_Core

    Sometimes my application never shows it. Consequently, my initializeGL override is never called and therefore I never call QOpenGLFunctions_3_3_Core::InitializeOpenGL. So QOpenGLFunctions_3_3_Core never initializes its backend pointers.

    That would be fine, but the problem is that when QOpenGLFunctions_3_3_Core is destroyed, it accesses these pointers as if they HAD been initialized

        if (d_1_0_Core)
        Q_ASSERT(d_1_0_Core->refs.load());  // BAD!!!  BAD!!!! CRASH!!!

    So whenever I run a DEBUG build, my app crashes on shutdown.. d_1_0_Core was never initialized. The ASSERT assumes it is valid --> Crash. Even though the line just above was checking for NULL.

    I'm assuming this is a Qt bug, right Is this correct? Is it something I should report? Or have I failed to follow some protocol?

    (I realize I can, if necessary, cause Paint to be called. I don't want to. I shouldn't have to).

    Appreciate any responses


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which version of Qt are you using ?

  • @SGaist Hi, Thanks for answering. Currently I am using Qt 5.7

  • Lifetime Qt Champion

    This has already been fixed in the dev branch

  • Excellent. Fortunately this only affects debug builds and only on shutdown so I guess I can wait for the next release. Thanks for the info

Log in to reply