From fd39d7eeec32fb29541decc11115608f9b759c86 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 29 Jan 2012 17:14:48 +0200 Subject: Do not start timers in QDeclarativePixmapStore teardown The store instance is a global static and so starting timers during its destruction is unnecessary, and may cause crashes if the QAbstractEventDispatcher's statics are already destroyed. This happens on OS X at least. Change-Id: I785515c8973b291a7bfc6c5dabe2c19e8393c7ad Reviewed-by: Martin Jones --- src/quick/util/qdeclarativepixmapcache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quick/util/qdeclarativepixmapcache.cpp b/src/quick/util/qdeclarativepixmapcache.cpp index 15a46375da..6460136775 100644 --- a/src/quick/util/qdeclarativepixmapcache.cpp +++ b/src/quick/util/qdeclarativepixmapcache.cpp @@ -707,17 +707,20 @@ private: int m_unreferencedCost; int m_timerId; + bool m_destroying; }; Q_GLOBAL_STATIC(QDeclarativePixmapStore, pixmapStore); QDeclarativePixmapStore::QDeclarativePixmapStore() -: m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1) + : m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1), m_destroying(false) { } QDeclarativePixmapStore::~QDeclarativePixmapStore() { + m_destroying = true; + int leakedPixmaps = 0; QList cachedData = m_cache.values(); @@ -764,7 +767,7 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data) shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit - if (m_timerId == -1 && m_unreferencedPixmaps) + if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying) m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000); } -- cgit v1.2.3