aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2016-06-10 15:13:31 +0200
committerKai Koehne <kai.koehne@qt.io>2016-06-23 09:11:53 +0000
commita3935184c4dbeda4f46e8140c9f75af1e58189f1 (patch)
tree9dabd43f51122ff8eb356ad1ee5281b147f348d2 /src/quickwidgets
parent6c16a50a51c1bafad71ab48c19ce98d57c005d25 (diff)
QQuickWidget: Fix crash when there's an offscreen window, but no real window context
Fix crash when creating a QQuickWidget where the offscreenWindow context is valid, but the window shareContext is not. This happens e.g. when QWebEngineWidgets is loaded, that creates a globally shared context. Task-number: QTBUG-54020 Change-Id: Ieeba0c20d12cce220b22cdd76adaf87d1ab2649e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r--src/quickwidgets/qquickwidget.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 6709d88fa3..7f869c6ba5 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -778,9 +778,10 @@ void QQuickWidget::createFramebufferObject()
return;
}
- if (context->shareContext() != QWidgetPrivate::get(window())->shareContext()) {
- context->setShareContext(QWidgetPrivate::get(window())->shareContext());
- context->setScreen(context->shareContext()->screen());
+ QOpenGLContext *shareWindowContext = QWidgetPrivate::get(window())->shareContext();
+ if (shareWindowContext && context->shareContext() != shareWindowContext) {
+ context->setShareContext(shareWindowContext);
+ context->setScreen(shareWindowContext->screen());
if (!context->create())
qWarning("QQuickWidget: Failed to recreate context");
// The screen may be different so we must recreate the offscreen surface too.