forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -1577,6 +1577,10 @@ QString Model::generateIdFromName(const QString &name, const QString &fallbackId
|
|||||||
newId.prepend('_');
|
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
|
QRegularExpression rgx("\\d+$"); // matches a number at the end of a string
|
||||||
while (hasId(newId)) { // id exists
|
while (hasId(newId)) { // id exists
|
||||||
QRegularExpressionMatch match = rgx.match(newId);
|
QRegularExpressionMatch match = rgx.match(newId);
|
||||||
|
Reference in New Issue
Block a user