Debugger: Use QRegularExpression in QmlInspector

Change-Id: Ib359738c07a5531fe66656bce5ad42c39e4a9ab2
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
hjk
2020-06-23 18:55:08 +02:00
parent 9efa934ae0
commit 5dd2985a65

View File

@@ -50,6 +50,7 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QFileInfo> #include <QFileInfo>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QRegularExpression>
using namespace QmlDebug; using namespace QmlDebug;
using namespace QmlDebug::Constants; using namespace QmlDebug::Constants;
@@ -555,10 +556,11 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref)
// handle the case where the url contains the revision number encoded. // handle the case where the url contains the revision number encoded.
// (for object created by the debugger) // (for object created by the debugger)
static QRegExp rx("(.*)_(\\d+):(\\d+)$"); const QRegularExpression rx("^(.*)_(\\d+):(\\d+)$");
if (rx.exactMatch(fileUrl.path())) { const QRegularExpressionMatch match = rx.match(fileUrl.path());
fileUrl.setPath(rx.cap(1)); if (match.hasMatch()) {
lineNum += rx.cap(3).toInt() - 1; fileUrl.setPath(match.captured(1));
lineNum += match.captured(3).toInt() - 1;
} }
const QString filePath = m_qmlEngine->toFileInProject(fileUrl); const QString filePath = m_qmlEngine->toFileInProject(fileUrl);