Commit d9ec96ab authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Marco Bubke

QmlDesigner: crash fix

prefixNames containing white spaces did crash.
This was lost during refactoring.
Instead of calling toLower one the string
we call toLower only on the first char.
This creates camel case ids.

Change-Id: I1093d12258e87d4f56ceef67a553d844afdfd376
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 882d0e35
......@@ -376,15 +376,26 @@ bool AbstractView::hasId(const QString &id) const
return model()->d->hasId(id);
}
QString firstCharToLower(const QString string)
{
QString resultString = string;
if (!resultString.isEmpty())
resultString[0] = resultString.at(0).toLower();
return resultString;
}
QString AbstractView::generateNewId(const QString prefixName) const
{
int counter = 1;
QString newId = QString("%1%2").arg(prefixName.toLower()).arg(counter);
QString newId = QString("%1%2").arg(firstCharToLower(prefixName)).arg(counter);
newId.remove(QRegExp(QLatin1String("[^a-zA-Z0-9_]")));
while (hasId(newId)) {
counter += 1;
newId = QString("%1%2").arg(prefixName.toLower()).arg(counter);
newId = QString("%1%2").arg(firstCharToLower(prefixName)).arg(counter);
}
return newId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment