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 { Q_OBJECT
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
QOpenGLFunctions_3_3_Core::~QOpenGLFunctions_3_3_Core() { if (d_1_0_Core) d_1_0_Core->refs.deref(); 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
-Joe
-
Hi and welcome to devnet,
Which version of Qt are you using ?
-
This has already been fixed in the dev branch