From e0c8dd9585651cd75a8e41f70c7de8cc1c00eb82 Mon Sep 17 00:00:00 2001 From: Simon De Backer Date: Wed, 23 Sep 2020 19:03:13 +0200 Subject: [PATCH] Fix Revert deprecated QRegExp Use QRegularExpression instead. https://doc.qt.io/qt-5/qregularexpression.html#notes-for-qregexp-users This function was introduced in Qt 5 see https://qelectrotech.org/forum/viewtopic.php?pid=13406#p13406 --- .../ElementsCollection/elementslocation.cpp | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp index 1fe3d90c7..addbf8e85 100644 --- a/sources/ElementsCollection/elementslocation.cpp +++ b/sources/ElementsCollection/elementslocation.cpp @@ -241,20 +241,36 @@ void ElementsLocation::setPath(const QString &path) //The path start with project, we get the project and the path from the string else if (tmp_path.startsWith("project")) { - QRegExp rx("^project([0-9]+)\\+(embed:\\/\\/.*)$", Qt::CaseInsensitive); - if (rx.exactMatch(tmp_path)) + QRegularExpression re + ("^project(?[0-9])\\+(?embed://*.*)$"); + if (!re.isValid()) { - bool conv_ok; - uint project_id = rx.capturedTexts().at(1).toUInt(&conv_ok); - if (conv_ok) - { - QETProject *project = QETApp::project(project_id); - if (project) - { - m_collection_path = rx.capturedTexts().at(2); - m_project = project; - } - } + qWarning() <<"this is an error in the code" + << re.errorString() + << re.patternErrorOffset(); + return; + } + QRegularExpressionMatch match = re.match(tmp_path); + if (!match.hasMatch()) + { + qDebug()<<"no Match => return"; + return; + } + bool conv_ok; + uint project_id = match.captured("project_id").toUInt(&conv_ok); + if (!conv_ok) + { + qWarning()<<"toUint failed" + <