Fixed QGLWidget not being able to be made current with a context.
If the QGLWidget's creation is triggered by a sibling or similar being created it would end up without the surface type OpenGLSurface. We need to make sure the QWindow has the correct surface type to prevent QOpenGLContext::makeCurrent() from failing. Task-number: QTBUG-30811 Change-Id: Ifc85f9120d89bd0bed4a3911233799830cb3a0f3 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>bb10
parent
146658a10f
commit
1f6ab6a661
|
|
@ -759,7 +759,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|
|||
return false;
|
||||
|
||||
if (surface->surfaceType() != QSurface::OpenGLSurface) {
|
||||
qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface";
|
||||
qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,15 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
|
|||
if (widget->testAttribute(Qt::WA_TranslucentBackground))
|
||||
winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8));
|
||||
|
||||
if (!widget->windowHandle()->handle()) {
|
||||
widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
|
||||
widget->windowHandle()->setFormat(winFormat);
|
||||
widget->winId();//make window
|
||||
QWindow *window = widget->windowHandle();
|
||||
if (!window->handle()
|
||||
|| window->surfaceType() != QWindow::OpenGLSurface
|
||||
|| window->requestedFormat() != winFormat)
|
||||
{
|
||||
window->setSurfaceType(QWindow::OpenGLSurface);
|
||||
window->setFormat(winFormat);
|
||||
window->destroy();
|
||||
window->create();
|
||||
}
|
||||
|
||||
if (d->ownContext)
|
||||
|
|
|
|||
Loading…
Reference in New Issue