aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgthreadedrenderloop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph/qsgthreadedrenderloop.cpp')
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 460f92edd7..e1a54810b7 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -490,6 +490,14 @@ void QSGRenderThread::sync(bool inExpose)
bool current = false;
if (windowSize.width() > 0 && windowSize.height() > 0)
current = gl->makeCurrent(window);
+ // Check for context loss.
+ if (!current && !gl->isValid()) {
+ QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown();
+ sgrc->invalidate();
+ current = gl->create() && gl->makeCurrent(window);
+ if (current)
+ sgrc->initialize(gl);
+ }
if (current) {
QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
bool hadRenderer = d->renderer != 0;
@@ -571,6 +579,12 @@ void QSGRenderThread::syncAndRender()
bool current = false;
if (d->renderer && windowSize.width() > 0 && windowSize.height() > 0)
current = gl->makeCurrent(window);
+ // Check for context loss.
+ if (!current && !gl->isValid()) {
+ // Cannot do anything here because gui is not locked. Request a new
+ // sync+render round on the gui thread and let the sync handle it.
+ QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)));
+ }
if (current) {
d->renderSceneGraph(windowSize);
if (profileFrames)
@@ -694,6 +708,11 @@ QSGThreadedRenderLoop::QSGThreadedRenderLoop()
m_animation_driver->install();
}
+QSGThreadedRenderLoop::~QSGThreadedRenderLoop()
+{
+ delete sg;
+}
+
QSGRenderContext *QSGThreadedRenderLoop::createRenderContext(QSGContext *sg) const
{
return sg->createRenderContext();