summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmapcache.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-10-21 08:44:10 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-10-23 00:16:01 +0000
commitbe926e412c9c4ec9ee77b49dbe370fbb5451f0e1 (patch)
tree9f6738e7c7fb6ea2cb2e45b947b5bc4c48485525 /src/gui/image/qpixmapcache.cpp
parentcefc3930597707293edb408dc251528f9277e78b (diff)
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 <gunnar@sletta.org>
Diffstat (limited to 'src/gui/image/qpixmapcache.cpp')
-rw-r--r--src/gui/image/qpixmapcache.cpp3
1 files changed, 2 insertions, 1 deletions
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.