aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgcontext.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-01-22 10:26:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 15:51:31 +0100
commit52a9d06bb028a16d9cf9be563a8ad1df09023439 (patch)
tree4036a59dc99a7390afb4310ab584d489ee34d176 /src/quick/scenegraph/qsgcontext.cpp
parentabc1cb32727a94ddac07020759c3c97382477cf9 (diff)
Enforce texture cleanup to happen at the end of the sync phase.
This was ok for the threaded renderer, but for the single-threaded renderers where the event loop was spinning we could run the risk of scheduling a texture for deleteLater() and then cleaning it up before we got around to the sync phase. Task-number: QTBUG-35670 Change-Id: I92074294b427fd8ab2a1823ba79c7ac3b59094ec Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 1eeb9441b8..829d33a0d7 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -358,6 +358,12 @@ QSGRenderContext::~QSGRenderContext()
invalidate();
}
+void QSGRenderContext::endSync()
+{
+ qDeleteAll(m_texturesToDelete);
+ m_texturesToDelete.clear();
+}
+
static QBasicMutex qsg_framerender_mutex;
void QSGRenderContext::renderNextFrame(QSGRenderer *renderer, GLuint fboId)
@@ -475,6 +481,9 @@ void QSGRenderContext::invalidate()
if (!m_gl)
return;
+ qDeleteAll(m_texturesToDelete);
+ m_texturesToDelete.clear();
+
qDeleteAll(m_textures.values());
m_textures.clear();
@@ -617,10 +626,8 @@ QSGTexture *QSGRenderContext::textureForFactory(QQuickTextureFactory *factory, Q
void QSGRenderContext::textureFactoryDestroyed(QObject *o)
{
m_mutex.lock();
- QSGTexture *t = m_textures.take(static_cast<QQuickTextureFactory *>(o));
+ m_texturesToDelete << m_textures.take(static_cast<QQuickTextureFactory *>(o));
m_mutex.unlock();
- if (t)
- t->deleteLater();
}
QT_END_NAMESPACE