-
Notifications
You must be signed in to change notification settings - Fork 333
Replace QRegExp with QRegularExpression #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
Echoing: #585 (comment) |
|
It seems the code is broken both in master and in this branch. It does not do what is supposed to do Line 313 in dd19c1a
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. |
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()) |
Agree. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
Labeled "Up for grabs"... |
|
Closing in favor of #620. |
67364eb test, qt: Add tests for `GUIUtil::extractFirstSuffixFromFilter` (w0xlt) ace9af5 qt: Replace `QRegExp` with `QRegularExpression` (w0xlt) c378535 qt: Add a function that extracts the suffix from a filter (w0xlt) Pull request description: Picking up bitcoin-core/gui#606 (labeled "Up for grabs") and applying bitcoin-core/gui#606 (review) and bitcoin-core/gui#606 (comment). Replaces occurrences of `QRegExp` usage with `QRegularExpression` as part of the roadmap for Qt6 integration. Fixes bitcoin-core/gui#578 ACKs for top commit: laanwj: Code review and lightly tested ACK 67364eb hebasto: ACK 67364eb Tree-SHA512: 4a17d83e557bc635cbd1a15776856e9edb7162b23a369ccbd2ac59c68b8a1ea663baaa7d5ad98e419dc03b91ef3315c768eeadc01c0b29162de109493161e814
Picking up #585
Replaces occurrences of QRegExp usage with QRegularExpression as part of the roadmap for Qt6 integration.
fixes #578