Fix dereferencing non-existent TLW with hidden QOpenGLWidget

Amends 2ea90c56f2.

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
// makes sense for properties that get picked up even after the native
// window is created.
QSurfaceFormat tlwFormat;
if (tlw->windowHandle())
tlwFormat = tlw->windowHandle()->format();
if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
// Most platforms will pick up the changed swap interval on the next
// makeCurrent or swapBuffers.
tlwFormat.setSwapInterval(requestedFormat.swapInterval());
tlw->windowHandle()->setFormat(tlwFormat);
}
if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
tlw->windowHandle()->setFormat(tlwFormat);
if (tlw->windowHandle()) {
QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
// Most platforms will pick up the changed swap interval on the next
// makeCurrent or swapBuffers.
tlwFormat.setSwapInterval(requestedFormat.swapInterval());
tlw->windowHandle()->setFormat(tlwFormat);
}
if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
tlw->windowHandle()->setFormat(tlwFormat);
}
}
// The top-level window's surface is not good enough since it causes way too