From 42e9a5e27c914c58dc9c734829f906fb7bb4f371 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 4 Apr 2017 11:36:19 +0200 Subject: Make QQuickWidget cleanup work with engines that alter the context To make Scene3D in a QQuickWidget work. Task-number: QTBUG-52132 Change-Id: I686ff36d82a1c7bdfdcd7080a314bb9afdb7be88 Reviewed-by: Sean Harmer Reviewed-by: Andy Nichols --- src/quickwidgets/qquickwidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 5d7fb04b9f..be5837723a 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -157,6 +157,16 @@ void QQuickWidgetPrivate::invalidateRenderControl() #endif renderControl->invalidate(); + + // Many things can happen inside the above invalidate() call, including a + // change of current context. Restore if needed since some code will rely + // on the fact that this function makes and leaves the context current. +#if QT_CONFIG(opengl) + if (!useSoftwareRenderer && context) { + if (QOpenGLContext::currentContext() != context) + context->makeCurrent(offscreenSurface); + } +#endif } void QQuickWidgetPrivate::handleWindowChange() -- cgit v1.2.3