From 85f46f2b485e166e469f2f2f32f2ea5d19117c85 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Thu, 10 Sep 2026 16:50:49 +1200 Subject: [PATCH] Use QLabel::pixmap()'s non-deprecated by-value form on Qt5 #824 read the pixmap through the pointer overload, which Qt 5.15 deprecates, so the fix it introduced compiled with two deprecation warnings of its own. Qt 5.15 offers the by-value form behind Qt::ReturnByValue, so both branches can take the same overload and the difference reduces to the argument. Equivalent: the pointer overload returns nullptr when no pixmap is set, which the old expression turned into a null QPixmap; pixmap( Qt::ReturnByValue) returns a null QPixmap directly. It also drops the null check, so the Qt5 branch is now a single expression. Verified both arms of the #if, since a preprocessor-branched change is only half tested otherwise: - Qt 5.15.18: deprecation warnings for this file 2 -> 0, builds clean, binary runs - Qt 6.10.2: builds clean, 488/488, links - 22 example projects load and export with no crash or hang Co-Authored-By: Claude Opus 5 --- sources/ui/imagetransparentcolordialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/ui/imagetransparentcolordialog.cpp b/sources/ui/imagetransparentcolordialog.cpp index e39b71802..180dfd54d 100644 --- a/sources/ui/imagetransparentcolordialog.cpp +++ b/sources/ui/imagetransparentcolordialog.cpp @@ -66,8 +66,11 @@ ClickableImageLabel::ClickableImageLabel(const QImage &sourceImage, QWidget *par void ClickableImageLabel::mousePressEvent(QMouseEvent *event) { // QLabel::pixmap() returns a pointer in Qt5 and a value in Qt6. + // Qt 5.15 offers the by-value form behind Qt::ReturnByValue; the + // pointer overload is deprecated there, so take the by-value one + // on both and the difference reduces to the argument. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - const QPixmap label_pixmap = pixmap() ? *pixmap() : QPixmap(); + const QPixmap label_pixmap = pixmap(Qt::ReturnByValue); #else const QPixmap label_pixmap = pixmap(); #endif