Fix dereferencing non-existent TLW with hidden QOpenGLWidget

Amends 2ea90c56f2924acc5c620ed7c29a48c72a42efd3.

Task-number: QTBUG-61280
Change-Id: Iae086a47f5cbe2e423b0831c3cd226507879cbbb
Reviewed-by: Mika Salmela <mika.salmela@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Laszlo Agocs 2017-06-16 15:24:55 +02:00
parent 932fe019fe
commit ccca8c9435

View File

@ -815,18 +815,18 @@ void QOpenGLWidgetPrivate::initialize()
// Propagate settings that make sense only for the tlw. Note that this only // Propagate settings that make sense only for the tlw. Note that this only
// makes sense for properties that get picked up even after the native // makes sense for properties that get picked up even after the native
// window is created. // window is created.
QSurfaceFormat tlwFormat; if (tlw->windowHandle()) {
if (tlw->windowHandle()) QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
tlwFormat = tlw->windowHandle()->format(); if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) { // Most platforms will pick up the changed swap interval on the next
// Most platforms will pick up the changed swap interval on the next // makeCurrent or swapBuffers.
// makeCurrent or swapBuffers. tlwFormat.setSwapInterval(requestedFormat.swapInterval());
tlwFormat.setSwapInterval(requestedFormat.swapInterval()); tlw->windowHandle()->setFormat(tlwFormat);
tlw->windowHandle()->setFormat(tlwFormat); }
} if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) { tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
tlwFormat.setSwapBehavior(requestedFormat.swapBehavior()); tlw->windowHandle()->setFormat(tlwFormat);
tlw->windowHandle()->setFormat(tlwFormat); }
} }
// The top-level window's surface is not good enough since it causes way too // The top-level window's surface is not good enough since it causes way too