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::~QOpenGLVertexArrayObject()
{
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::~QOpenGLVertexArrayObject() failed to make VAO's context current");
ctx = 0;
}
}
if (ctx)
destroy();
if (oldContext) {
if (!oldContext->makeCurrent(oldContext->surface()))
qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
}
}
/*!
Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.
*/
QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()
{
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::~QOpenGLVertexArrayObject() failed to make VAO's context current");
ctx = 0;
}
}
if (ctx)
destroy();
if (oldContext) {
if (!oldContext->makeCurrent(oldContext->surface()))
qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
}
}
To copy to clipboard, switch view to plain text mode
- Is it possible to use QOpenGLVertexArrayObjects in a QGLWidget that's not currently visible and close the program successfully?
- Is this a bug?
Bookmarks