Replace QRegExp with QRegularExpression #606

pull jarolrod wants to merge 1 commits into bitcoin-core:master from jarolrod:regexp-obsolete changing 2 files +11 −9
  1. jarolrod commented at 11:28 PM on May 24, 2022: member

    Picking up #585

    Replaces occurrences of QRegExp usage with QRegularExpression as part of the roadmap for Qt6 integration.

    fixes #578

  2. qt: replace QRegExp with QRegularExpression dd19c1a2c6
  3. jarolrod commented at 11:28 PM on May 24, 2022: member
  4. jarolrod added the label Refactoring on May 24, 2022
  5. jarolrod added the label Qt 6 on May 24, 2022
  6. hebasto commented at 10:48 AM on May 25, 2022: member

    Concept ACK.

    Suggesting to apply clang-format-diff.py and use QStringLiteral macro:

    --- a/src/qt/utilitydialog.cpp
    +++ b/src/qt/utilitydialog.cpp
    @@ -23,6 +23,7 @@
     #include <QLabel>
     #include <QMainWindow>
     #include <QRegularExpression>
    +#include <QString>
     #include <QTextCursor>
     #include <QTextTable>
     #include <QVBoxLayout>
    @@ -44,8 +45,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
             /// HTML-format the license message from the core
             QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
             // Make URLs clickable
    -        QRegularExpression uri("<(.*)>", QRegularExpression::InvertedGreedinessOption);
    -        licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
    +        QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption);
    +        licenseInfoHTML.replace(uri, QStringLiteral("<a href=\"\\1\">\\1</a>"));
             // Replace newlines with HTML breaks
             licenseInfoHTML.replace("\n", "<br>");
     
    

    Still reviewing guiutil.cpp changes.

  7. hebasto commented at 10:54 AM on May 25, 2022: member

    Echoing: #585 (comment)

  8. hebasto commented at 11:49 AM on May 25, 2022: member

    It seems the code is broken both in master and in this branch. It does not do what is supposed to do https://github.com/bitcoin-core/gui/blob/dd19c1a2c69f84c73b8d3734c34c011ad3b9e18f/src/qt/guiutil.cpp#L313

    I mean, it fails to extract first suffix from filter pattern "Description (*.foo *.bar ...)".

    However, all of the callers in our codebase do not use patterns with multiple suffixes.

  9. hebasto commented at 11:57 AM on May 25, 2022: member

    I mean, it fails to extract first suffix from filter pattern "Description (*.foo *.bar ...)".

    Ok, an inversion of greediness will help:

    --- a/src/qt/guiutil.cpp
    +++ b/src/qt/guiutil.cpp
    @@ -311,7 +311,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption, const QString &
         QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
     
         /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
    -    QRegularExpression filter_re(".* \\(\\*\\.(.*)[ \\)]");
    +    QRegularExpression filter_re(QStringLiteral(".* \\(\\*\\.(.*)[ \\)]"), QRegularExpression::InvertedGreedinessOption);
         QString selectedSuffix;
         QRegularExpressionMatch m = filter_re.match(selectedFilter);
         if(m.hasMatch())
    
  10. promag commented at 4:58 PM on May 26, 2022: contributor

    Echoing: #585 (comment)

    Agree.

  11. hebasto added the label Waiting for author on May 29, 2022
  12. DrahtBot commented at 9:44 PM on June 12, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  13. hebasto added the label Up for grabs on Jun 20, 2022
  14. hebasto commented at 12:28 PM on June 20, 2022: member

    Labeled "Up for grabs"...

  15. fanquake removed the label Up for grabs on Jun 20, 2022
  16. hebasto commented at 2:48 PM on June 20, 2022: member

    Closing in favor of #620.

  17. hebasto closed this on Jun 20, 2022

  18. laanwj referenced this in commit 58b9d6cf9e on Jun 22, 2022
  19. bitcoin-core locked this on Jun 20, 2023

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: 2026-04-14 18:20 UTC

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