avoid temporary in QItemDelegate::selected()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-14 21:39:22 +03:00
parent 443516dafa
commit a779a4742f

View file

@ -1005,12 +1005,11 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.fillRect(0, 0, img.width(), img.height(), color);
painter.end();
QPixmap selected = QPixmap::fromImage(img);
int n = (img.byteCount() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
QPixmapCache::insert(key, selected);
QPixmapCache::insert(key, QPixmap::fromImage(img));
pm = QPixmapCache::find(key);
}
return pm;