diff options
author | Kai Koehne <kai.koehne@qt.io> | 2016-06-10 15:13:31 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2016-06-23 09:11:53 +0000 |
commit | a3935184c4dbeda4f46e8140c9f75af1e58189f1 (patch) | |
tree | 9dabd43f51122ff8eb356ad1ee5281b147f348d2 | |
parent | 6c16a50a51c1bafad71ab48c19ce98d57c005d25 (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>
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 7 |
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. |