Skip to content

Commit 1248b34

Browse files
albumart-qt: Stop using deprecated QLabel pixmap function
It is deprecated since Qt 6.6 but not causing a compiler warning for some reason. Simplify and unify the code at the same time. See also: https://doc.qt.io/qt-6/qlabel-obsolete.html#pixmap
1 parent 2afeaa3 commit 1248b34

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/albumart-qt/albumart.cc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,26 @@ class ArtLabel : public QLabel {
7979
}
8080

8181
protected:
82-
virtual void resizeEvent (QResizeEvent * event)
82+
void resizeEvent (QResizeEvent * event) override
8383
{
8484
QLabel::resizeEvent (event);
8585

86-
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
87-
QPixmap pm = pixmap (Qt::ReturnByValue);
88-
if (! origPixmap.isNull () && ! pm.isNull () &&
89-
(size ().width () <= origSize.width () + MARGIN ||
90-
size ().height () <= origSize.height () + MARGIN ||
91-
pm.size ().width () != origSize.width () ||
92-
pm.size ().height () != origSize.height ()))
93-
drawArt ();
86+
QPixmap pm;
87+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
88+
pm = pixmap ();
89+
#elif QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
90+
pm = pixmap (Qt::ReturnByValue);
9491
#else
95-
const QPixmap * pm = pixmap ();
96-
if (! origPixmap.isNull () && pm && ! pm->isNull () &&
97-
(size ().width () <= origSize.width () + MARGIN ||
98-
size ().height () <= origSize.height () + MARGIN ||
99-
pm->size ().width () != origSize.width () ||
100-
pm->size ().height () != origSize.height ()))
101-
drawArt ();
92+
if (const QPixmap * ptr = pixmap ())
93+
pm = *ptr;
10294
#endif
95+
if (! origPixmap.isNull () && ! pm.isNull () &&
96+
(size ().width () <= origSize.width () + MARGIN ||
97+
size ().height () <= origSize.height () + MARGIN ||
98+
pm.size () != origSize))
99+
{
100+
drawArt ();
101+
}
103102
}
104103

105104
private:

0 commit comments

Comments
 (0)