PDA

View Full Version : QOpenGLVertexArrayObject crash if QGLWidget not visible on close action



alketi
11th November 2015, 20:42
I have a Qt 5.2.1 program that uses QOpenGLVertexArrayObjects and creates more than one QGLWidget, each placed inside of a QStackedWidget. Thus, only one QGLWidget is visible at any one time.

The issue is -- if I close the program and the QGLWidget that uses a QOpenGLVertexArrayObject ISN'T currently visible, it crashes with the message:


Warning: QOpenGLVertexArrayObject::~QOpenGLVertexArrayObjec t() failed to make VAO's context current (opengl/qopenglvertexarrayobject.cpp:370, virtual QOpenGLVertexArrayObject::~QOpenGLVertexArrayObjec t())


Looking through the source code, the destructor of QOpenGLVertexArrayObject contains the following code:



/*!
Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.
*/
QOpenGLVertexArrayObject::~QOpenGLVertexArrayObjec t()
{
QOpenGLContext* ctx = QOpenGLContext::currentContext();

Q_D(QOpenGLVertexArrayObject);
QOpenGLContext *oldContext = 0;
if (d->context && ctx && d->context != ctx) {
oldContext = ctx;
if (d->context->makeCurrent(oldContext->surface())) {
ctx = d->context;
} else {
qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObjec t() failed to make VAO's context current");
ctx = 0;
}
}

if (ctx)
destroy();

if (oldContext) {
if (!oldContext->makeCurrent(oldContext->surface()))
qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObjec t() failed to restore current context");
}
}

- Is it possible to use QOpenGLVertexArrayObjects in a QGLWidget that's not currently visible and close the program successfully?

- Is this a bug?

ChrisW67
13th November 2015, 20:42
The warning issued is not a crash. Where does it crash? Have you looked at the backtrace?