Add check for global share context for QOpenGLWidget initialize

Fixes: QTBUG-78863
Change-Id: I678f66a2057fb9c98863e19eb09042306e72f68a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Michal Klocek 2019-09-30 15:27:19 +02:00
parent 0c1d23db7b
commit ce2fc51914

View File

@ -788,10 +788,12 @@ void QOpenGLWidgetPrivate::initialize()
if (initialized) if (initialized)
return; return;
// Get our toplevel's context with which we will share in order to make the // If no global shared context get our toplevel's context with which we
// texture usable by the underlying window's backingstore. // will share in order to make the texture usable by the underlying window's backingstore.
QWidget *tlw = q->window(); 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. // If shareContext is null, showing content on-screen will not work.
// However, offscreen rendering and grabFramebuffer() will stay fully functional. // However, offscreen rendering and grabFramebuffer() will stay fully functional.