This PR:
- Removes outdated Qt version-specific code.
- Inlines two functions from
GUIUtil
.
This PR:
GUIUtil
.
Since bitcoin/bitcoin#30997, the minimum supported Qt version is 6.2.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | davidgumberg |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
91@@ -92,7 +92,11 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
92
93 QImage QRImageWidget::exportImage()
94 {
95- return GUIUtil::GetImage(this);
96+ if (!GUIUtil::HasPixmap(this)) {
97+ return QImage();
98+ }
99+
100+ return this->pixmap(Qt::ReturnByValue).toImage();
Micro-Nit:
As far as I understand this is deprecated in favor of QLabel::pixmap()
at least as early as QT 6.2 (https://doc.qt.io/archives/qt-6.2/qlabel-obsolete.html#pixmap) and was marked obsolete
in 6.0 (https://doc.qt.io/archives/qt-6.0/qlabel-obsolete.html#pixmap)
Previously, it was recommended to use QLabel::pixmap(Qt::ReturnByValue)
to maintain compatibility with old code, since previously QLabel::pixmap()
returned a pixmap by pointer. (https://doc.qt.io/qt-5/qlabel.html#pixmap-prop)
0 return this->pixmap().toImage();
crACK https://github.com/bitcoin-core/gui/pull/863/commits/3aa58bea8e703e33a1eb8e2f9fdf887aca8d03c1
Nice cleanup, doesn’t change any behavior, mostly drops workaround code for versions of QT < 6.2.
Left an insignificant nit about use of deprecated QLabel::pixmap(Qt::ReturnByValue())
, but this can be addressed in a follow up (or here, if the author prefers) with the other place it appears.
(https://github.com/davidgumberg/gui/commit/ca5390f9b0af348e8f4ea0cf2149716c0b77bd8f)
0diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
1@@ -959,7 +959,7 @@ QDateTime StartOfDay(const QDate& date)
2 bool HasPixmap(const QLabel* label)
3 {
4- return !label->pixmap(Qt::ReturnByValue).isNull();
5+ return !label->pixmap().isNull();
6 }
7
8diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp
9@@ -96,7 +96,7 @@ QImage QRImageWidget::exportImage()
10 return QImage();
11 }
12- return this->pixmap(Qt::ReturnByValue).toImage();
13+ return this->pixmap().toImage();
14 }
crACK 3aa58be
Nice cleanup, doesn’t change any behavior, mostly drops workaround code for versions of QT < 6.2.
Thank you for your review!
Left an insignificant nit about use of deprecated
QLabel::pixmap(Qt::ReturnByValue())
, but this can be addressed in a follow up (or here, if the author prefers) with the other place it appears.0diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp 1@@ -959,7 +959,7 @@ QDateTime StartOfDay(const QDate& date) 2 bool HasPixmap(const QLabel* label) 3 { 4- return !label->pixmap(Qt::ReturnByValue).isNull(); 5+ return !label->pixmap().isNull(); 6 } 7 8diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp 9@@ -96,7 +96,7 @@ QImage QRImageWidget::exportImage() 10 return QImage(); 11 } 12- return this->pixmap(Qt::ReturnByValue).toImage(); 13+ return this->pixmap().toImage(); 14 }
I agree with your comment and suggested changes. I also agree that this can be addressed in a follow-up, along with other closely related changes, such as inlining the QRImageWidget::exportImage()
function.
Labels
Refactoring