From 25348752a3c48a8914f79141098db0eec810ebe0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 22 Jun 2020 15:37:37 +0200 Subject: QQuickWidget: do not crash when failing to make context current ...in createFramebufferObject(), e.g. upon resizing. Certain systems have a problem with OpenGL contexts during resizing, according to user reports. We do not know why makeCurrent() would fail, so we cannot prevent the failure, but we can check the result of makeCurrent() and not go on doing GL stuff (which would almost certainly crash) without a valid context. Task-number: QTBUG-83319 Pick-to: 5.15 Change-Id: I50a4f4e06d636fa0ee41fb9b80e720500711854f Reviewed-by: Andy Nichols --- src/quickwidgets/qquickwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 6fea6c6689..2da5e21fb8 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1032,7 +1032,11 @@ void QQuickWidget::createFramebufferObject() d->offscreenSurface->create(); } - d->context->makeCurrent(d->offscreenSurface); + bool current = d->context->makeCurrent(d->offscreenSurface); + if (!current) { + qWarning("QQuickWidget: Failed to make context current when creating FBO"); + return; + } int samples = d->requestedSamples; if (!QOpenGLExtensions(d->context).hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) -- cgit v1.2.3