From be926e412c9c4ec9ee77b49dbe370fbb5451f0e1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 21 Oct 2015 08:44:10 -0700 Subject: Prevent the pixmap cache from crashing if it's been destroyed In case the static destructor has already been run, make sure we don't crash. This shouldn't happen, but could happen if the QApplication destructor is run in a weird order (after the static destructors have begun running). That's not usually a case we'd fix (unsupported), but since this change improves the code and also avoids creating the pixmap cache if it hadn't been used up until this point, the change is a net benefit. Task-number: QTBUG-48709 Change-Id: Ia505aece07bf4e13a1faffff140f3e119cfc773e Reviewed-by: Gunnar Sletta --- src/gui/image/qpixmapcache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index de37e0ab44..d29ddcf978 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -642,7 +642,8 @@ void QPixmapCache::remove(const Key &key) void QPixmapCache::clear() { QT_TRY { - pm_cache()->clear(); + if (pm_cache.exists()) + pm_cache->clear(); } QT_CATCH(const std::bad_alloc &) { // if we ran out of memory during pm_cache(), it's no leak, // so just ignore it. -- cgit v1.2.3