From 28b138cbc21c4bed7b18b70bb98a690d000ad2f9 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 30 Sep 2019 15:27:19 +0200 Subject: Add check for global share context for QOpenGLWidget initialize Fixes: QTBUG-78863 Change-Id: I678f66a2057fb9c98863e19eb09042306e72f68a (cherry picked from commit ce2fc51914f809369d5096e7a0621229dd9eaef9) Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qopenglwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 7aef74c507..e58994b04c 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -788,10 +788,12 @@ void QOpenGLWidgetPrivate::initialize() if (initialized) return; - // Get our toplevel's context with which we will share in order to make the - // texture usable by the underlying window's backingstore. + // If no global shared context get our toplevel's context with which we + // will share in order to make the texture usable by the underlying window's backingstore. QWidget *tlw = q->window(); - QOpenGLContext *shareContext = get(tlw)->shareContext(); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) + shareContext = get(tlw)->shareContext(); // If shareContext is null, showing content on-screen will not work. // However, offscreen rendering and grabFramebuffer() will stay fully functional. -- cgit v1.2.3