From cb764eaf91e3a8ef30b280671d5c991ec926d14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 14 Sep 2010 14:18:27 +0200 Subject: 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 --- src/opengl/qpaintengine_opengl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index fc31548..5c3ea58 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(context->device()); - connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*))); + if (context->isValid()) { + if (context->device()->devType() == QInternal::Widget) { + QWidget *widget = static_cast(context->device()); + connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*))); + } connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), SLOT(cleanupContext(const QGLContext*))); -- cgit v0.12