aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-12-14 09:44:40 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-12-15 10:56:48 +0000
commit93de0b0e3d11d761bcfd94283dc6b5e86c12d87f (patch)
treeff81125f16ae9004155030ff3b992756b2e00cc3 /src
parent946c48d83158e64d4e66ba338d73ff79fac5e0c3 (diff)
Fix crash when grabbing a QQuickWidget before it is shown.
Do not access null share contexts. Task-number: QTBUG-49929 Change-Id: I1c88563df71dd6c5d186b6f2ae147614fcc6ded9 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/quickwidgets/qquickwidget.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 748b450643..2120be768c 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -724,12 +724,13 @@ void QQuickWidgetPrivate::createContext()
context = new QOpenGLContext;
context->setFormat(offscreenWindow->requestedFormat());
- if (qt_gl_global_share_context())
- context->setShareContext(qt_gl_global_share_context());
- else
- context->setShareContext(QWidgetPrivate::get(q->window())->shareContext());
- context->setScreen(context->shareContext()->screen());
-
+ QOpenGLContext *shareContext = qt_gl_global_share_context();
+ if (!shareContext)
+ shareContext = QWidgetPrivate::get(q->window())->shareContext();
+ if (shareContext) {
+ context->setShareContext(shareContext);
+ context->setScreen(shareContext->screen());
+ }
if (!context->create()) {
const bool isEs = context->isOpenGLES();
delete context;