mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[UserList] Prevent failed loads from poisoning the banner card art cache (#7170)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
daa0dcb2ea
commit
648b472bfb
1 changed files with 8 additions and 3 deletions
|
|
@ -39,7 +39,10 @@ void UserCardArtProvider::requestCardArt(const QString &userName, const QString
|
|||
|
||||
const QString key = makeKey(userName, cardName, providerId);
|
||||
|
||||
if (cardArtCache.contains(key) || pending.contains(key)) {
|
||||
if (pending.contains(key)) {
|
||||
return;
|
||||
}
|
||||
if (cardArtCache.contains(key) && !cardArtCache.value(key).isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +66,10 @@ QPixmap UserCardArtProvider::cropCardArt(const QPixmap &fullRes)
|
|||
|
||||
void UserCardArtProvider::insertIntoCache(const QString &key, const QPixmap &pixmap)
|
||||
{
|
||||
if (pixmap.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cardArtCache.contains(key)) {
|
||||
cacheInsertionOrder.append(key);
|
||||
while (cacheInsertionOrder.size() > MaxCacheEntries) {
|
||||
|
|
@ -129,8 +136,6 @@ void UserCardArtProvider::processQueue()
|
|||
|
||||
if (!fullRes.isNull()) {
|
||||
self->insertIntoCache(key, self->cropCardArt(fullRes));
|
||||
} else {
|
||||
self->insertIntoCache(key, QPixmap());
|
||||
}
|
||||
|
||||
self->pending.remove(key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue