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.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
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)
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.
<details>
<summary>
(https://github.com/davidgumberg/gui/commit/ca5390f9b0af348e8f4ea0cf2149716c0b77bd8f)
</summary>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
@@ -959,7 +959,7 @@ QDateTime StartOfDay(const QDate& date)
bool HasPixmap(const QLabel* label)
{
- return !label->pixmap(Qt::ReturnByValue).isNull();
+ return !label->pixmap().isNull();
}
diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp
@@ -96,7 +96,7 @@ QImage QRImageWidget::exportImage()
return QImage();
}
- return this->pixmap(Qt::ReturnByValue).toImage();
+ return this->pixmap().toImage();
}
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.diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp @@ -959,7 +959,7 @@ QDateTime StartOfDay(const QDate& date) bool HasPixmap(const QLabel* label) { - return !label->pixmap(Qt::ReturnByValue).isNull(); + return !label->pixmap().isNull(); } diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp @@ -96,7 +96,7 @@ QImage QRImageWidget::exportImage() return QImage(); } - return this->pixmap(Qt::ReturnByValue).toImage(); + return this->pixmap().toImage(); }
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.