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>
This commit is contained in:
parent
cefc393059
commit
be926e412c
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user