summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-10-25 15:58:49 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-10-25 16:02:41 +0200
commit207fb45ce7bac66ab53a0770d2bfb50d8d1997d8 (patch)
tree6b5d28f80776977abc54b84f6ab542256176092c /src
parent8051a73be276995adfc4508a0cb5ad6451e8ab45 (diff)
Fix possible crash in glyph cache when deleting and creating contexts
The freeResource(), used in the glyph cache as a notifier of when the owner context of the cache disappears, is never called if the context is in a group with other contexts that share its resources. This implements a second notifier function instead which can be used to invalidate the glyph cache when its context is destroyed. Task-number: QTBUG-22324 Reviewed-by: Samuel
Diffstat (limited to 'src')
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h4
-rw-r--r--src/opengl/qgl.cpp11
-rw-r--r--src/opengl/qgl_p.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index 83ca06d040..1a8bb0bb71 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -144,6 +144,10 @@ public:
void clear();
+ void contextDeleted(const QGLContext *context) {
+ if (ctx == context)
+ ctx = 0;
+ }
void freeResource(void *) { ctx = 0; }
private:
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 423fa08a1f..eaaf9a8569 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -5722,6 +5722,11 @@ void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx)
}
}
+void QGLContextGroupResourceBase::contextDeleted(const QGLContext *ctx)
+{
+ Q_UNUSED(ctx);
+}
+
void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value)
{
#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
@@ -5737,12 +5742,16 @@ void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value)
void QGLContextGroup::cleanupResources(const QGLContext *context)
{
+ // Notify all resources that a context has been deleted
+ QHash<QGLContextGroupResourceBase *, void *>::ConstIterator it;
+ for (it = m_resources.begin(); it != m_resources.end(); ++it)
+ it.key()->contextDeleted(context);
+
// If there are still shares, then no cleanup to be done yet.
if (m_shares.size() > 1)
return;
// Iterate over all resources and free each in turn.
- QHash<QGLContextGroupResourceBase *, void *>::ConstIterator it;
for (it = m_resources.begin(); it != m_resources.end(); ++it)
it.key()->cleanup(context, it.value());
}
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index de349a759d..b6fc96a55c 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -725,6 +725,7 @@ public:
void cleanup(const QGLContext *context);
void cleanup(const QGLContext *context, void *value);
virtual void freeResource(void *value) = 0;
+ virtual void contextDeleted(const QGLContext *ctx);
protected:
QList<QGLContextGroup *> m_groups;