summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/compiled/submachineA.scxml2
-rw-r--r--tests/auto/compiled/submachineB.scxml2
-rw-r--r--tools/qscxmlc/qscxmlc.cpp9
3 files changed, 10 insertions, 3 deletions
diff --git a/tests/auto/compiled/submachineA.scxml b/tests/auto/compiled/submachineA.scxml
index b72a048..0924b2e 100644
--- a/tests/auto/compiled/submachineA.scxml
+++ b/tests/auto/compiled/submachineA.scxml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine">
<final id="topState"/>
</scxml>
diff --git a/tests/auto/compiled/submachineB.scxml b/tests/auto/compiled/submachineB.scxml
index b72a048..0924b2e 100644
--- a/tests/auto/compiled/submachineB.scxml
+++ b/tests/auto/compiled/submachineB.scxml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine">
<final id="topState"/>
</scxml>
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);
}