diff options
Diffstat (limited to 'src/openglwidgets/qopenglwidget.cpp')
-rw-r--r-- | src/openglwidgets/qopenglwidget.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/openglwidgets/qopenglwidget.cpp b/src/openglwidgets/qopenglwidget.cpp index cbc0b751e85..d1d4dd5d792 100644 --- a/src/openglwidgets/qopenglwidget.cpp +++ b/src/openglwidgets/qopenglwidget.cpp @@ -780,9 +780,7 @@ void QOpenGLWidgetPrivate::ensureRhiDependentResources() { Q_Q(QOpenGLWidget); - QRhi *rhi = nullptr; - if (QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(q->window())->maybeRepaintManager()) - rhi = repaintManager->rhi(); + QRhi *rhi = QWidgetPrivate::rhi(); // If there is no rhi, because we are completely offscreen, then there's no wrapperTexture either if (rhi && rhi->backend() == QRhi::OpenGLES2) { @@ -828,7 +826,6 @@ void QOpenGLWidgetPrivate::initialize() // 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(); - QWidgetPrivate *tlwd = get(tlw); // Do not include the sample count. Requesting a multisampled context is not necessary // since we render into an FBO, never to an actual surface. What's more, attempting to @@ -837,9 +834,7 @@ void QOpenGLWidgetPrivate::initialize() requestedSamples = requestedFormat.samples(); requestedFormat.setSamples(0); - QRhi *rhi = nullptr; - if (QWidgetRepaintManager *repaintManager = tlwd->maybeRepaintManager()) - rhi = repaintManager->rhi(); + QRhi *rhi = QWidgetPrivate::rhi(); // Could be that something else already initialized the window with some // other graphics API for the QRhi, that's not good. @@ -856,9 +851,11 @@ void QOpenGLWidgetPrivate::initialize() context = new QOpenGLContext; context->setFormat(requestedFormat); - if (contextFromRhi) { - context->setShareContext(contextFromRhi); - context->setScreen(contextFromRhi->screen()); + + QOpenGLContext *shareContext = contextFromRhi ? contextFromRhi : qt_gl_global_share_context(); + if (shareContext) { + context->setShareContext(shareContext); + context->setScreen(shareContext->screen()); } if (Q_UNLIKELY(!context->create())) { qWarning("QOpenGLWidget: Failed to create context"); @@ -1687,8 +1684,8 @@ bool QOpenGLWidget::event(QEvent *e) if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) d->reset(); } - if (QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(window())->maybeRepaintManager()) { - if (!d->initialized && !size().isEmpty() && repaintManager->rhi()) { + if (d->rhi()) { + if (!d->initialized && !size().isEmpty()) { d->initialize(); if (d->initialized) { d->recreateFbos(); |