diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-07-29 15:59:40 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-07-29 21:48:09 +0200 |
commit | 0b0bb319578bb2e2eced3a80ce3876a4408b72a7 (patch) | |
tree | 8ecb43bbcab1ea5dcd12d5fbba8dfc17e9452219 /src/quick/items/qquickrendercontrol.cpp | |
parent | 15ce5d915b6bda4bf1d3c85cbdc79b2e11690bca (diff) |
Invalidate the scenegraph properly in the rendercontrol's stop()
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.
Task-number: QTBUG-40435
Change-Id: Iaa3b950e60ec36783a12074d706e1a501573f110
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/items/qquickrendercontrol.cpp')
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 3a287242e0..005ee72037 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -251,10 +251,6 @@ bool QQuickRenderControl::sync() This is the equivalent of the cleanup operations that happen with a real QQuickWindow when the window becomes hidden. - This function takes QQuickWindow::persistentSceneGraph() into - account, meaning that context-specific resources are not released - when persistency is enabled. - This function is called from the destructor. Therefore there will typically be no need to call it directly. Pay attention however to the fact that this requires the context, that was passed to @@ -263,6 +259,11 @@ bool QQuickRenderControl::sync() Once stop() has been called, it is possible to reuse the QQuickRenderControl instance by calling initialize() again. + + \note This function does not take + QQuickWindow::persistentSceneGraph() or + QQuickWindow::persistentOpenGLContext() into account. This means + that context-specific resources are always released. */ void QQuickRenderControl::stop() { @@ -273,17 +274,15 @@ void QQuickRenderControl::stop() if (!d->window) return; - if (!QOpenGLContext::currentContext()) - return; - QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); 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); d->initialized = false; } |