diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-09-20 16:44:24 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-09-20 13:53:53 +0000 |
commit | b080376f70cfa729d2911730276ed943c40f9c96 (patch) | |
tree | f2ba0573836fd0b96fd153ecc1b6739441f661f8 | |
parent | 6b8e2fbd49a5982fac84f8747c3d14b72feb4f0a (diff) | |
download | qt-creator-b080376f70cfa729d2911730276ed943c40f9c96.tar.gz |
QmlDesigner: Fix renaming materials
Check for id validity during id generation and try to fix invalid id.
Fixes: QDS-7437
Change-Id: I9d7665cbebdce8ee3395e4abe9ee14b26866f761
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/model.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index f6f852bf47..ef4e3cb2f7 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -1577,6 +1577,10 @@ QString Model::generateIdFromName(const QString &name, const QString &fallbackId newId.prepend('_'); } + // If the new id is not valid (e.g. qml keyword match), try fixing it by prepending underscore + if (!ModelNode::isValidId(newId)) + newId.prepend("_"); + QRegularExpression rgx("\\d+$"); // matches a number at the end of a string while (hasId(newId)) { // id exists QRegularExpressionMatch match = rgx.match(newId); |