diff --git a/sources/factory/elementpicturefactory.cpp b/sources/factory/elementpicturefactory.cpp index 4dd11ff0f..0c27a8690 100644 --- a/sources/factory/elementpicturefactory.cpp +++ b/sources/factory/elementpicturefactory.cpp @@ -569,11 +569,23 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa #pragma message("@TODO remove code for QT 5.14 or later") const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts); #endif - QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); + QRegularExpression rx("^(?[a-z-]+): (?[a-z-]+)$"); + if (!rx.isValid()) + { + qWarning() <<"this is an error in the code" + << rx.errorString() + << rx.patternErrorOffset(); + return; + } for (QString style : styles) { - if (rx==QRegularExpression(style)) { - QString style_name = rx.namedCaptureGroups().at(1); - QString style_value = rx.namedCaptureGroups().at(2); + QRegularExpressionMatch match = rx.match(style); + if (!match.hasMatch()) + { + qDebug()<<"no Match" + < void QETApp::addWindowsListToMenu( or -1 if none could be found. */ int QETApp::projectIdFromString(const QString &url) { - QRegularExpression embedded("^project([0-9]+)\\+embed.*$", QRegularExpression::CaseInsensitiveOption); - if (embedded==QRegularExpression(url)) { - bool conv_ok = false; - int project_id = embedded.namedCaptureGroups().at(1).toInt(&conv_ok); - if (conv_ok) { - return(project_id); - } + QRegularExpression embedded( + "^project(?[0-9]+)\\+embed.*$", + QRegularExpression::CaseInsensitiveOption); + if (!embedded.isValid()) + { + qWarning() <<"this is an error in the code" + << embedded.errorString() + << embedded.patternErrorOffset(); + return(-1); + } + QRegularExpressionMatch match = embedded.match(url); + if (!match.hasMatch()) + { + qDebug()<<"no Match => return" + < #include #include +#include /** Constructeur @@ -36,7 +37,7 @@ QFileNameEdit::QFileNameEdit(QWidget *parent) : QLineEdit(parent) { */ QFileNameEdit::QFileNameEdit(const QString &contents, QWidget *parent) : QLineEdit(parent) { init(); - if (!contents.isEmpty() && regexp_==QRegularExpression(contents)) { + if (!contents.isEmpty() && regexp_.match(contents).hasMatch()) { setText(contents); } } @@ -61,7 +62,7 @@ bool QFileNameEdit::isEmpty() */ bool QFileNameEdit::isValid() { - return(regexp_==QRegularExpression(text())); + return(regexp_.match(text()).hasMatch()); } /**