https://github.com/hluk/CopyQ/commit/42c02f2dc74b188ea7982a30c38acaf668bbf76a From 42c02f2dc74b188ea7982a30c38acaf668bbf76a Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mon, 4 Sep 2023 21:12:44 +0200 Subject: [PATCH] Avoid showing warnings about invalid regex --- a/src/scriptable/scriptableitemselection.cpp +++ b/src/scriptable/scriptableitemselection.cpp @@ -46,10 +46,6 @@ QVector toIntVector(const QJSValue &value) QRegularExpression toRegularExpression(const QJSValue &value) { - // If argument is invalid/not-regexp, create an invalid regex to match nothing. - if ( !value.isRegExp() ) - return QRegularExpression("("); - const QVariant variant = value.toVariant(); QRegularExpression regexp = variant.toRegularExpression(); @@ -136,7 +132,7 @@ QJSValue ScriptableItemSelection::selectAll() QJSValue ScriptableItemSelection::select(const QJSValue &re, const QString &mimeFormat) { - const QVariant regexp = re.isUndefined() ? QVariant() : toRegularExpression(re); + const QVariant regexp = re.isRegExp() ? toRegularExpression(re) : QVariant(); m_proxy->selectionSelect(m_id, regexp, mimeFormat); return m_self; } --- a/src/tests/testinterface.h +++ b/src/tests/testinterface.h @@ -85,9 +85,6 @@ class TestInterface { /// Clean up tabs and items. Return error string on error. virtual QByteArray cleanup() = 0; - /// Ignore given text in logs for current unit test. - virtual void setIgnoreError(const QByteArray &ignoreError) = 0; - /// Platform specific key to remove (usually Delete, Backspace on OS X). virtual QString shortcutToRemove() = 0; --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -150,8 +150,6 @@ bool testStderr(const QByteArray &stderrData, TestInterface::ReadStderrFlag flag // Ignore exceptions and errors from clients in application log // (these are expected in some tests). static const std::vector ignoreList{ - plain("[EXPECTED-IN-TEST]"), - regex(R"(CopyQ Note \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\] setIgnoreError("QtWarning: QString::contains: invalid QRegularExpression object"); + RUN(args << "add" << "", ""); RUN(args << "ItemSelection().select('A').str()", outRows.arg("")); - m_test->setIgnoreError(QByteArray()); } void Tests::classItemSelectionGetCurrent()