aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonrunconfiguration.cpp
diff options
context:
space:
mode:
authorDavid Schulz <[email protected]>2025-06-19 11:41:33 +0200
committerDavid Schulz <[email protected]>2025-06-23 12:38:10 +0000
commitcc7fb061a791a26206dc795af0d5d1737b2a072b (patch)
treef1219c317285c1da4b48667c1b1b40ed7ff67b2b /src/plugins/python/pythonrunconfiguration.cpp
parent0e36d79d1379c2243c74dd89db55fd3e086aaf2c (diff)
Python: use static QRegularExpression
Change-Id: I91662f3922c7bf730164de205cf41efa5b12099e Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins/python/pythonrunconfiguration.cpp')
-rw-r--r--src/plugins/python/pythonrunconfiguration.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp
index c46fa373ede..55c17efa9ab 100644
--- a/src/plugins/python/pythonrunconfiguration.cpp
+++ b/src/plugins/python/pythonrunconfiguration.cpp
@@ -28,12 +28,16 @@ using namespace Utils;
namespace Python::Internal {
+static const QRegularExpression &tracebackFilePattern()
+{
+ static const QRegularExpression s_filePattern("^(\\s*)(File \"([^\"]+)\", line (\\d+), .*$)");
+ return s_filePattern;
+}
+
class PythonOutputLineParser : public OutputLineParser
{
public:
PythonOutputLineParser()
- // Note that moc dislikes raw string literals.
- : filePattern("^(\\s*)(File \"([^\"]+)\", line (\\d+), .*$)")
{
TaskHub::clearTasks(PythonErrorTaskCategory);
}
@@ -50,7 +54,7 @@ private:
}
const Id category(PythonErrorTaskCategory);
- const QRegularExpressionMatch match = filePattern.match(text);
+ const QRegularExpressionMatch match = tracebackFilePattern().match(text);
if (match.hasMatch()) {
const LinkSpec link(match.capturedStart(2), match.capturedLength(2), match.captured(2));
const auto fileName = FilePath::fromString(match.captured(3));
@@ -85,7 +89,7 @@ private:
bool handleLink(const QString &href) final
{
- const QRegularExpressionMatch match = filePattern.match(href);
+ const QRegularExpressionMatch match = tracebackFilePattern().match(href);
if (!match.hasMatch())
return false;
const QString fileName = match.captured(3);
@@ -94,7 +98,6 @@ private:
return true;
}
- const QRegularExpression filePattern;
QList<Task> m_tasks;
bool m_inTraceBack = false;
};