Skip to content
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

replace QRegExp with QRegularExpression #4289

Merged
merged 3 commits into from
Sep 19, 2021

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Sep 16, 2021

QRegExp has been removed in Qt6.

// devices that have an equivalent "deviceName" and ### section.
const QRegularExpression midiDeviceNameRegex("^(.*) MIDI (\\d+)( .*)?$");

const QRegularExpression inputRegex("^(.*) in (\\d+)( .*)?$");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work, is more efficient, and easier to read:

const QRegularExpression kInputRegex = QStringLiteral("^(.*) in (\\d+)( .*)?$");

Also the naming of constants doesn't comply with our coding style.

const QRegExp kForbiddenChars =
QRegExp("[<>:\"\\/|?*\\\\]|(\\.\\.)"
const QRegularExpression kForbiddenChars =
QRegularExpression(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple use QStringLiteral(...) instead of QRegularExpression(...).

src/preferences/colorpalettesettings.cpp Show resolved Hide resolved
@Be-ing
Copy link
Contributor Author

Be-ing commented Sep 17, 2021

I don't know what's going on with GitHub... I didn't merge nor close this PR??

@Be-ing
Copy link
Contributor Author

Be-ing commented Sep 17, 2021

I'm puzzled by these test failures:

❯ ctest --rerun-failed --output-on-failure
Test project /home/be/sw/mixxx/build
    Start 558: SearchQueryParserTest.NumericFilterOperators
1/2 Test #558: SearchQueryParserTest.NumericFilterOperators .....................***Failed    0.40 sec
QML debugging is enabled. Only use this in a safe environment.
Note: Google Test filter = SearchQueryParserTest.NumericFilterOperators
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from SearchQueryParserTest
[ RUN      ] SearchQueryParserTest.NumericFilterOperators
../src/test/searchqueryparsertest.cpp:462: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:463: Failure
Expected equality of these values:
  QtPrivate::asString(QString("bpm >= 127.12")).toLocal8Bit().constData()
    Which is: "bpm >= 127.12"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:480: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:481: Failure
Expected equality of these values:
  QtPrivate::asString(QString("bpm <= 127.12")).toLocal8Bit().constData()
    Which is: "bpm <= 127.12"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
info [0x1f2e130] TrackCollection - Disconnecting database
info [0x1f2e130] GlobalTrackCache - Destroying instance
[  FAILED  ] SearchQueryParserTest.NumericFilterOperators (18 ms)
[----------] 1 test from SearchQueryParserTest (18 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (18 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] SearchQueryParserTest.NumericFilterOperators

 1 FAILED TEST

    Start 563: SearchQueryParserTest.HumanReadableDurationSearchWithOperators
2/2 Test #563: SearchQueryParserTest.HumanReadableDurationSearchWithOperators ...***Failed    0.18 sec
QML debugging is enabled. Only use this in a safe environment.
Note: Google Test filter = SearchQueryParserTest.HumanReadableDurationSearchWithOperators
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from SearchQueryParserTest
[ RUN      ] SearchQueryParserTest.HumanReadableDurationSearchWithOperators
../src/test/searchqueryparsertest.cpp:609: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:610: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration >= 90")).toLocal8Bit().constData()
    Which is: "duration >= 90"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:618: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:619: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration >= 90")).toLocal8Bit().constData()
    Which is: "duration >= 90"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:636: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:637: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration <= 150")).toLocal8Bit().constData()
    Which is: "duration <= 150"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:645: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:646: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration <= 150")).toLocal8Bit().constData()
    Which is: "duration <= 150"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:654: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:655: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration <= 150")).toLocal8Bit().constData()
    Which is: "duration <= 150"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:663: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:664: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration <= 120")).toLocal8Bit().constData()
    Which is: "duration <= 120"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:672: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:673: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration <= 120")).toLocal8Bit().constData()
    Which is: "duration <= 120"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
../src/test/searchqueryparsertest.cpp:681: Failure
Value of: pQuery->match(pTrack)
  Actual: false
Expected: true
../src/test/searchqueryparsertest.cpp:682: Failure
Expected equality of these values:
  QtPrivate::asString(QString("duration >= 63")).toLocal8Bit().constData()
    Which is: "duration >= 63"
  QtPrivate::asString(pQuery->toSql()).toLocal8Bit().constData()
    Which is: ""
info [0x2365130] TrackCollection - Disconnecting database
info [0x2365130] GlobalTrackCache - Destroying instance
[  FAILED  ] SearchQueryParserTest.HumanReadableDurationSearchWithOperators (16 ms)
[----------] 1 test from SearchQueryParserTest (16 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (16 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] SearchQueryParserTest.HumanReadableDurationSearchWithOperators

 1 FAILED TEST


0% tests passed, 2 tests failed out of 2

Total Test time (real) =   0.60 sec

The following tests FAILED:
        558 - SearchQueryParserTest.NumericFilterOperators (Failed)
        563 - SearchQueryParserTest.HumanReadableDurationSearchWithOperators (Failed)
Errors while running CTest

@uklotzde
Copy link
Contributor

This is really strange, zero changes?!

@Be-ing Be-ing reopened this Sep 17, 2021
@Be-ing
Copy link
Contributor Author

Be-ing commented Sep 17, 2021

It looks like my most recent changes were lost?? I cherry-picked a commit from my reflog...

@Be-ing
Copy link
Contributor Author

Be-ing commented Sep 17, 2021

I think what happened before was that I accidentally amended by commit in this branch to the latest commit in the main branch which confused GitHub.

@Be-ing
Copy link
Contributor Author

Be-ing commented Sep 17, 2021

Any ideas why SearchQueryParserTest.NumericFilterOperators and SearchQueryParserTest.HumanReadableDurationSearchWithOperators are failing? These features seem to work fine using them from the GUI.

@uklotzde
Copy link
Contributor

Any ideas why SearchQueryParserTest.NumericFilterOperators and SearchQueryParserTest.HumanReadableDurationSearchWithOperators are failing? These features seem to work fine using them from the GUI.

I am also clueless 🤷 Didn't find any cause for this failure. Probably some undiscovered undefined behavior somewhere in the query parser?

@uklotzde
Copy link
Contributor

Any ideas why SearchQueryParserTest.NumericFilterOperators and SearchQueryParserTest.HumanReadableDurationSearchWithOperators are failing? These features seem to work fine using them from the GUI.

I am also clueless shrug Didn't find any cause for this failure. Probably some undiscovered undefined behavior somewhere in the query parser?

Fixed: Be-ing#58

src/track/keyutils.cpp Show resolved Hide resolved
src/util/regex.h Outdated Show resolved Hide resolved
src/util/regex.h Outdated Show resolved Hide resolved
@uklotzde
Copy link
Contributor

Thank you! LGTM

@uklotzde uklotzde merged commit d480aa0 into mixxxdj:main Sep 19, 2021
@jospezial
Copy link

On Gentoo with 5.15.2 git from kde:

FAILED: CMakeFiles/mixxx-lib.dir/src/skin/legacy/legacyskin.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -DMIXXX_BUILD_RELEASE -DNDEBUG -DPA_USE_ALSA -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICKWIDGETS_LIB -DQT_QUICK_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_TABLET_SUPPORT -DQT_TESTCASE_BUILDDIR=\"/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999_build\" -DQT_TESTLIB_LIB -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -DQT_X11EXTRAS_LIB -DQT_XML_LIB -DSFC_SUPPORTS_SET_COMPRESSION_LEVEL -D__BATTERY__ -D__BULK__ -D__FAAD__ -D__FFMPEG__ -D__HID__ -D__KEYFINDER__ -D__LILV__ -D__LINUX__ -D__MAD__ -D__MODPLUG__ -D__MP4V2__ -D__OPUS__ -D__QTKEYCHAIN__ -D__SNDFILE__ -D__SQLITE3__ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__UNIX__ -D__VINYLCONTROL__ -D__WV__ -Dx86_64 -I/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999_build/mixxx-lib_autogen/include -I/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src -I/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999_build/src -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/fidlib -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/googletest/googletest/include -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/portaudio -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/rigtorp/SPSCQueue/include -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/replaygain -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/reverb -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/kaitai -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/mp3guessenc-0.27.4 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtConcurrent -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtOpenGL -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtPrintSupport -isystem /usr/include/qt5/QtQml -isystem /usr/include/qt5/QtQuickWidgets -isystem /usr/include/qt5/QtQuick -isystem /usr/include/qt5/QtQmlModels -isystem /usr/include/qt5/QtSql -isystem /usr/include/qt5/QtSvg -isystem /usr/include/qt5/QtTest -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtX11Extras -isystem /usr/include/qt5/QtDBus -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/qm-dsp -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/qm-dsp/include -isystem /usr/include/taglib -isystem /usr/include/libupower-glib -isystem /usr/include/lilv-0 -isystem /usr/include/opus -isystem /usr/include/hidapi -isystem /usr/include/libusb-1.0 -isystem /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/lib/xwax -isystem /usr/include/wavpack  -march=native -mtune=native -O2 -pipe -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Wall -Wextra -Woverloaded-virtual -Wfloat-conversion -Werror=return-type -Wformat=2 -Wformat-security -Wvla -Wundef -pthread -fPIC -std=gnu++17 -MD -MT CMakeFiles/mixxx-lib.dir/src/skin/legacy/legacyskin.cpp.o -MF CMakeFiles/mixxx-lib.dir/src/skin/legacy/legacyskin.cpp.o.d -o CMakeFiles/mixxx-lib.dir/src/skin/legacy/legacyskin.cpp.o -c /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:8:40: error: variable ‘const QRegularExpression {anonymous}::kMinSizeRegExp’ has initializer but incomplete type
    8 | const QRegularExpression kMinSizeRegExp(QStringLiteral("<MinimumSize>(\\d+), *(\\d+)<"));
      |                                        ^
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:9:37: error: variable ‘const QRegularExpression {anonymous}::kDigitRegex’ has initializer but incomplete type
    9 | const QRegularExpression kDigitRegex(QStringLiteral("\\d"));
      |                                     ^
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp: In member function ‘virtual bool mixxx::skin::legacy::LegacySkin::fitsScreenSize(const QScreen&) const’:
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:93:33: error: aggregate ‘QRegularExpressionMatch match’ has incomplete type and cannot be defined
   93 |         QRegularExpressionMatch match;
      |                                 ^~~~~
ninja: build stopped: subcommand failed.

@Be-ing Be-ing deleted the qregularexpression branch November 7, 2021 17:51
@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 7, 2021

That cannot be reproduced on CI or developers' machines so my guess is the problem is Gentoo's packaging somehow. Anyway, if you want to add some #includes to resolve it, please make a pull request.

Holzhaus added a commit to Holzhaus/mixxx that referenced this pull request Nov 7, 2021
Should fix a build error:

    /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:8:40: error: variable ‘const QRegularExpression {anonymous}::kMinSizeRegExp’ has initializer but incomplete type
        8 | const QRegularExpression kMinSizeRegExp(QStringLiteral("<MinimumSize>(\\d+), *(\\d+)<"));
          |                                        ^
    /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:9:37: error: variable ‘const QRegularExpression {anonymous}::kDigitRegex’ has initializer but incomplete type
        9 | const QRegularExpression kDigitRegex(QStringLiteral("\\d"));
          |                                     ^
    /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp: In member function ‘virtual bool mixxx::skin::legacy::LegacySkin::fitsScreenSize(const QScreen&) const’:
    /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/skin/legacy/legacyskin.cpp:93:33: error: aggregate ‘QRegularExpressionMatch match’ has incomplete type and cannot be defined
       93 |         QRegularExpressionMatch match;
          |                                 ^~~~~

Reported here: mixxxdj#4289 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants