summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-09-14 14:18:27 +0200
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 13:06:52 +0300
commit53eb7c5ee84dd2bfab11d94fb26448b9a94d5380 (patch)
tree6417093223866fd1685ad057f79af4d0aad64507
parente5f73c552c3ccffc5a1dae959d81cba5b03a916a (diff)
Prevent crash in QGLGlyphCache due to dangling context references.
We need to clear the context from the cache when it's destroyed even if it doesn't belong to a widget. Task-number: QTBUG-13622 Reviewed-by: Trond (cherry picked from commit cb764eaf91e3a8ef30b280671d5c991ec926d14c)
-rw-r--r--src/opengl/qpaintengine_opengl.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 15fb932f4d..e954e1d88f 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -4737,9 +4737,11 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti,
font_cache = new QGLFontGlyphHash;
// qDebug() << "new context" << context << font_cache;
qt_context_cache.insert(context, font_cache);
- if (context->isValid() && context->device()->devType() == QInternal::Widget) {
- QWidget *widget = static_cast<QWidget *>(context->device());
- connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
+ if (context->isValid()) {
+ if (context->device()->devType() == QInternal::Widget) {
+ QWidget *widget = static_cast<QWidget *>(context->device());
+ connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
+ }
connect(QGLSignalProxy::instance(),
SIGNAL(aboutToDestroyContext(const QGLContext*)),
SLOT(cleanupContext(const QGLContext*)));