QPixmapCache: ignore insertion or searches with empty key
When a key for a pixmap cannot be generated, then the only meaningful way to indicate that failure is to return an empty string. Instead of plastering checks for the generated key being empty all over our styling code, reject attempts to insert a pixmap with an empty key string in the QPixmapCache, and fail to find immediately. Such a key makes no sense either way. [ChangeLog][Gui][QPixmapCache] Trying to insert or find a pixmap with an empty key string now always fails immediately. Task-number: QTBUG-114473 Change-Id: I15bf8064ac7a4fe715722d98f2df2b8608809c7f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 79abdd3cd496b472f0a6140fcf94e68ff79fda2b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5cf68eb150
commit
d117cd5f3a
@ -428,7 +428,7 @@ QPixmapCacheEntry::~QPixmapCacheEntry()
|
|||||||
|
|
||||||
bool QPixmapCache::find(const QString &key, QPixmap *pixmap)
|
bool QPixmapCache::find(const QString &key, QPixmap *pixmap)
|
||||||
{
|
{
|
||||||
if (!qt_pixmapcache_thread_test())
|
if (key.isEmpty() || !qt_pixmapcache_thread_test())
|
||||||
return false;
|
return false;
|
||||||
QPixmap *ptr = pm_cache()->object(key);
|
QPixmap *ptr = pm_cache()->object(key);
|
||||||
if (ptr && pixmap)
|
if (ptr && pixmap)
|
||||||
@ -480,7 +480,7 @@ bool QPixmapCache::find(const Key &key, QPixmap *pixmap)
|
|||||||
|
|
||||||
bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap)
|
bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
if (!qt_pixmapcache_thread_test())
|
if (key.isEmpty() || !qt_pixmapcache_thread_test())
|
||||||
return false;
|
return false;
|
||||||
return pm_cache()->insert(key, pixmap, cost(pixmap));
|
return pm_cache()->insert(key, pixmap, cost(pixmap));
|
||||||
}
|
}
|
||||||
@ -562,7 +562,7 @@ void QPixmapCache::setCacheLimit(int n)
|
|||||||
*/
|
*/
|
||||||
void QPixmapCache::remove(const QString &key)
|
void QPixmapCache::remove(const QString &key)
|
||||||
{
|
{
|
||||||
if (!qt_pixmapcache_thread_test())
|
if (key.isEmpty() || !qt_pixmapcache_thread_test())
|
||||||
return;
|
return;
|
||||||
pm_cache()->remove(key);
|
pm_cache()->remove(key);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user