aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets/qquickwidget.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-06-09 17:08:47 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-06-09 17:08:47 +0300
commit960a980dc885622cb84990c4da75d5060318302d (patch)
treeb02009bb0e08ec4f94f2ef1d4318679700347d9a /src/quickwidgets/qquickwidget.cpp
parent540c4e4a5def8c350a49bb68380b787ae62490c6 (diff)
parentcecf9b52904ab790e1a531698e9c5e33585227f0 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.11' into tqtc/lts-5.15-opensourcev5.15.11-lts-lgpl
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r--src/quickwidgets/qquickwidget.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 39780f8de3..cf021d9a7c 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -978,11 +978,14 @@ void QQuickWidget::createFramebufferObject()
}
QOpenGLContext *shareWindowContext = QWidgetPrivate::get(window())->shareContext();
+ bool nativeContextGotRecreated = false;
if (shareWindowContext && context->shareContext() != shareWindowContext && !qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) {
+ d->invalidateRenderControl();
context->setShareContext(shareWindowContext);
context->setScreen(shareWindowContext->screen());
if (!context->create())
qWarning("QQuickWidget: Failed to recreate context");
+ nativeContextGotRecreated = true;
// The screen may be different so we must recreate the offscreen surface too.
// Unlike QOpenGLContext, QOffscreenSurface's create() does not recreate so have to destroy() first.
d->offscreenSurface->destroy();
@@ -1042,6 +1045,10 @@ void QQuickWidget::createFramebufferObject()
// Having one would mean create() was called and platforms that only support
// a single native window were in trouble.
Q_ASSERT(!d->offscreenWindow->handle());
+
+ // do this at the end it may trigger a recursive call
+ if (nativeContextGotRecreated)
+ d->renderControl->initialize(context);
#endif
}