aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-05 14:53:34 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-08 09:58:00 +0200
commite823bb5aee09c8a9f4a11bfd9ab6c68d2a77e93e (patch)
tree2e75f21f09597681b4f2717410c352689adc7fb9 /src
parentf14f713c2fd42e94abe55b8fc1b4dabffaa15fda (diff)
Invalidate the scenegraph properly in the rendercontrol
Taking the persistent flags from the QQuickWindow was a bad idea. These are not applicable to the case when an application drives the scene via QQuickRenderControl. Once stop() is called, all resources must be released since the context itself will typically be destroyed afterwards. This is a backport of 0b0bb319578bb2e2eced3a80ce3876a4408b72a7 in dev. On top of this, stop() becomes invalidate() since the original invalidate() function is never used by anyone. This naming is much cleaner and is consistent with QSGContext and friends. Task-number: QTBUG-40505 Task-number: QTBUG-40435 Change-Id: I398f1bda31f335c3508b238f0328305d3cd79ffd Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickrendercontrol.cpp17
-rw-r--r--src/quick/items/qquickrendercontrol_p.h1
-rw-r--r--src/quickwidgets/qquickwidget.cpp12
-rw-r--r--src/quickwidgets/qquickwidget_p.h2
4 files changed, 13 insertions, 19 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 2842d7e933..e28669ceb3 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -123,12 +123,6 @@ void QQuickRenderControl::initialize(QOpenGLContext *gl)
d->rc->initialize(gl);
}
-void QQuickRenderControl::invalidate()
-{
- Q_D(QQuickRenderControl);
- d->rc->invalidate();
-}
-
/*!
This function should be called as late as possible before
sync(). In a threaded scenario, rendering can happen in parallel with this function.
@@ -165,7 +159,7 @@ bool QQuickRenderControl::sync()
Stop rendering and release resources. This function is typically
called when the window is hidden. Requires a current context.
*/
-void QQuickRenderControl::stop()
+void QQuickRenderControl::invalidate()
{
Q_D(QQuickRenderControl);
if (!d->window)
@@ -175,10 +169,11 @@ void QQuickRenderControl::stop()
cd->fireAboutToStop();
cd->cleanupNodesOnShutdown();
- if (!cd->persistentSceneGraph) {
- d->rc->invalidate();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- }
+ // We must invalidate since the context can potentially be destroyed by the
+ // application right after returning from this function. Invalidating is
+ // also essential to allow a subsequent initialize() to succeed.
+ d->rc->invalidate();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
}
/*!
diff --git a/src/quick/items/qquickrendercontrol_p.h b/src/quick/items/qquickrendercontrol_p.h
index cc30e37724..d8d5b09a9c 100644
--- a/src/quick/items/qquickrendercontrol_p.h
+++ b/src/quick/items/qquickrendercontrol_p.h
@@ -74,7 +74,6 @@ public:
void polishItems();
void render();
bool sync();
- void stop();
QImage grab();
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 77d16222d2..8a61e371e7 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -116,23 +116,23 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
}
-void QQuickWidgetPrivate::stopRenderControl()
+void QQuickWidgetPrivate::invalidateRenderControl()
{
if (!context) // this is not an error, could be called before creating the context, or multiple times
return;
bool success = context->makeCurrent(offscreenSurface);
if (!success) {
- qWarning("QQuickWidget::stopRenderControl could not make context current");
+ qWarning("QQuickWidget::invalidateRenderControl could not make context current");
return;
}
- renderControl->stop();
+ renderControl->invalidate();
}
void QQuickWidgetPrivate::handleWindowChange()
{
- stopRenderControl();
+ invalidateRenderControl();
destroyContext();
}
@@ -158,7 +158,7 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate()
if (QQmlDebugService::isDebuggingEnabled())
QQmlInspectorService::instance()->removeView(q_func());
- stopRenderControl();
+ invalidateRenderControl();
// context and offscreenSurface are current at this stage, if the context was created.
Q_ASSERT(!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface));
@@ -964,7 +964,7 @@ void QQuickWidget::showEvent(QShowEvent *)
void QQuickWidget::hideEvent(QHideEvent *)
{
Q_D(QQuickWidget);
- d->stopRenderControl();
+ d->invalidateRenderControl();
}
/*! \reimp */
diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h
index 356c34e7f5..8a8d98f45e 100644
--- a/src/quickwidgets/qquickwidget_p.h
+++ b/src/quickwidgets/qquickwidget_p.h
@@ -92,7 +92,7 @@ public:
void init(QQmlEngine* e = 0);
void handleWindowChange();
- void stopRenderControl();
+ void invalidateRenderControl();
QSize rootObjectSize() const;