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:

     0--- a/src/qt/utilitydialog.cpp
     1+++ b/src/qt/utilitydialog.cpp
     2@@ -23,6 +23,7 @@
     3 #include <QLabel>
     4 #include <QMainWindow>
     5 #include <QRegularExpression>
     6+#include <QString>
     7 #include <QTextCursor>
     8 #include <QTextTable>
     9 #include <QVBoxLayout>
    10@@ -44,8 +45,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
    11         /// HTML-format the license message from the core
    12         QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
    13         // Make URLs clickable
    14-        QRegularExpression uri("<(.*)>", QRegularExpression::InvertedGreedinessOption);
    15-        licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
    16+        QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption);
    17+        licenseInfoHTML.replace(uri, QStringLiteral("<a href=\"\\1\">\\1</a>"));
    18         // Replace newlines with HTML breaks
    19         licenseInfoHTML.replace("\n", "<br>");
    20 
    

    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:

     0--- a/src/qt/guiutil.cpp
     1+++ b/src/qt/guiutil.cpp
     2@@ -311,7 +311,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption, const QString &
     3     QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
     4 
     5     /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
     6-    QRegularExpression filter_re(".* \\(\\*\\.(.*)[ \\)]");
     7+    QRegularExpression filter_re(QStringLiteral(".* \\(\\*\\.(.*)[ \\)]"), QRegularExpression::InvertedGreedinessOption);
     8     QString selectedSuffix;
     9     QRegularExpressionMatch m = filter_re.match(selectedFilter);
    10     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

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

    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: 2024-11-23 09:20 UTC

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