refactor: Post Qt 6 cleanup #863

pull hebasto wants to merge 3 commits into bitcoin-core:master from hebasto:250402-qt-version changing 10 files +6 −85
  1. hebasto commented at 7:54 pm on April 2, 2025: member

    This PR:

    • Removes outdated Qt version-specific code.
    • Inlines two functions from GUIUtil.
  2. qt, refactor: Remove outdated Qt version-specific code
    Since bitcoin/bitcoin#30997, the minimum supported Qt version is 6.2.
    4b36ab3a6a
  3. qt, refactor: Inline `GUIUtil::GetImage` function d1ec6db249
  4. qt, refactor: Inline `GUIUtil::SplitSkipEmptyParts` function 3aa58bea8e
  5. hebasto added the label Refactoring on Apr 2, 2025
  6. DrahtBot commented at 7:54 pm on April 2, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    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.

  7. in src/qt/qrimagewidget.cpp:99 in d1ec6db249 outdated
     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();
    


    davidgumberg commented at 8:50 pm on April 2, 2025:

    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();
    
  8. davidgumberg commented at 9:34 pm on April 2, 2025: contributor

    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 }
    
  9. hebasto commented at 7:43 am on April 3, 2025: member

    @davidgumberg

    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.

    (davidgumberg@ca5390f)

     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.

  10. hebasto merged this on Apr 3, 2025
  11. hebasto closed this on Apr 3, 2025

  12. hebasto deleted the branch on Apr 3, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-04-18 18:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me