summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2016-07-26 14:43:36 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2016-07-28 08:02:14 +0000
commit1b002a4aa4ef2eaf863e6d036ca92da2305a8bfd (patch)
tree4780450ffc515d1c676cd96be71620fe426a8f3d /tools
parent07eeac08a42f481fb3e599e212d032e1983f4f63 (diff)
Generate unique class names for sub machines
Change-Id: I3a83e12a611a6c4c2ab86a45b44e168b62bb7da3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qscxmlc/qscxmlc.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp
index d5217d8..d362b25 100644
--- a/tools/qscxmlc/qscxmlc.cpp
+++ b/tools/qscxmlc/qscxmlc.cpp
@@ -236,9 +236,16 @@ int run(const QStringList &arguments)
tu.outCppFileName = outCppFileName;
for (QMap<DocumentModel::ScxmlDocument *, QString>::const_iterator i = docs.begin(), ei = docs.end(); i != ei; ++i) {
auto name = i.value();
+ auto prefix = name;
if (name.isEmpty()) {
- name = QStringLiteral("%1_StateMachine_%2").arg(mainClassName).arg(tu.classnameForDocument.size() + 1);
+ prefix = QStringLiteral("%1_StateMachine").arg(mainClassName);
+ name = prefix;
}
+
+ int counter = 1;
+ while (tu.classnameForDocument.key(name) != nullptr)
+ name = QStringLiteral("%1_%2").arg(prefix).arg(++counter);
+
tu.classnameForDocument.insert(i.key(), name);
}