diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qscxmlc/data.t | 4 | ||||
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.cpp | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/qscxmlc/data.t b/tools/qscxmlc/data.t index a1eece5..c9150de 100644 --- a/tools/qscxmlc/data.t +++ b/tools/qscxmlc/data.t @@ -69,9 +69,7 @@ ${classname}::~${classname}() QScxmlInvokableServiceFactory *${classname}::Data::serviceFactory(int id) const { - switch (id) { - ${serviceFactories} - } +${serviceFactories} } std::vector<QString> ${classname}::Data::outgoingEvents = { diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp index d261b22..3446e4d 100644 --- a/tools/qscxmlc/scxmlcppdumper.cpp +++ b/tools/qscxmlc/scxmlcppdumper.cpp @@ -626,8 +626,15 @@ void CppDumper::writeImplBody(const GeneratedTableData &table, name = QStringLiteral("string(%1)").arg(table.theName); } - QString serviceFactories = factory.join(QStringLiteral("\n ")) - + QStringLiteral("\n default: Q_UNREACHABLE();"); + QString serviceFactories; + if (factory.isEmpty()) { + serviceFactories = QStringLiteral(" Q_UNUSED(id);\n Q_UNREACHABLE();"); + } else { + serviceFactories = QStringLiteral(" switch (id) {\n ") + + factory.join(QStringLiteral("\n ")) + + QStringLiteral("\n default: Q_UNREACHABLE();\n }"); + } + Replacements r; r[QStringLiteral("classname")] = className; |