From 2fe53ba6e88d610a6fef7b43b0562a16dae09b4b Mon Sep 17 00:00:00 2001 From: Simon De Backer Date: Wed, 23 Sep 2020 22:19:13 +0200 Subject: [PATCH] Fix QRegularExpression -add isValid -add debug --- sources/conductorproperties.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 4d368e6b8..bedd970f0 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -19,6 +19,7 @@ #include #include #include +#include /** Constructeur par defaut */ @@ -789,16 +790,32 @@ void ConductorProperties::readStyle(const QString &style_string) { QStringList styles = style_string.split(";", Qt::SkipEmptyParts); #endif - QRegularExpression Rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$"); - foreach (QString style_str, styles) { - if (Rx==QRegularExpression(style_str)) { - - QString style_name = Rx.namedCaptureGroups().at(1); - QString style_value = Rx.namedCaptureGroups().at(2); + QRegularExpression Rx("^(?[a-z-]+): (?[a-z-]+)$"); + if (!Rx.isValid()) + { + qWarning() <<"this is an error in the code" + << Rx.errorString() + << Rx.patternErrorOffset(); + return; + } + foreach (QString style_str, styles) + { + QRegularExpressionMatch match = Rx.match(style_str); + if (!match.hasMatch()) + { + qDebug()<<"no Match" + <