summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-03-15 16:22:18 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-11-10 12:42:28 +0000
commit3d23818472e371745f4ad4bd4b6c92de3d119e34 (patch)
tree48ca0b1186ef5b85655355a05552ac559b44d8ee
parent113b502b194d6d7573b9f86f400bdf481e98cf74 (diff)
Output a better warning when runtime-loading malformed SCXML
The document might technically have a root element. We might not be able to read it, though. Also, output all errors without quotes. Change-Id: I8133e322e452ea0c3d079b5cbe23aed2f2952b3e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/scxml/qscxmlcompiler.cpp11
-rw-r--r--tests/auto/parser/tst_parser.cpp3
2 files changed, 11 insertions, 3 deletions
diff --git a/src/scxml/qscxmlcompiler.cpp b/src/scxml/qscxmlcompiler.cpp
index 626015b..f259eee 100644
--- a/src/scxml/qscxmlcompiler.cpp
+++ b/src/scxml/qscxmlcompiler.cpp
@@ -685,7 +685,7 @@ QScxmlScxmlService *invokeDynamicScxmlService(const QString &sourceUrl,
if (!compiler.errors().isEmpty()) {
const auto errors = compiler.errors();
for (const QScxmlError &error : errors)
- qWarning() << error.toString();
+ qWarning().noquote() << error.toString();
return Q_NULLPTR;
}
@@ -694,7 +694,7 @@ QScxmlScxmlService *invokeDynamicScxmlService(const QString &sourceUrl,
Q_ASSERT(!compiler.errors().isEmpty());
const auto errors = compiler.errors();
for (const QScxmlError &error : errors)
- qWarning() << error.toString();
+ qWarning().noquote() << error.toString();
return Q_NULLPTR;
}
@@ -847,7 +847,12 @@ void QScxmlCompilerPrivate::instantiateDataModel(QScxmlStateMachine *stateMachin
#ifdef BUILD_QSCXMLC
Q_UNUSED(stateMachine)
#else
- auto doc = scxmlDocument();
+ if (!m_errors.isEmpty()) {
+ qWarning() << "SCXML document has errors";
+ return;
+ }
+
+ auto doc = m_doc.data();
auto root = doc ? doc->root : Q_NULLPTR;
if (root == Q_NULLPTR) {
qWarning() << "SCXML document has no root element";
diff --git a/tests/auto/parser/tst_parser.cpp b/tests/auto/parser/tst_parser.cpp
index 202e783..0e7436d 100644
--- a/tests/auto/parser/tst_parser.cpp
+++ b/tests/auto/parser/tst_parser.cpp
@@ -69,6 +69,9 @@ void tst_Parser::error()
const QStringList expectedErrors =
QString::fromUtf8(errorFile.readAll()).split('\n', QString::SkipEmptyParts);
+ if (!expectedErrors.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "SCXML document has errors");
+
QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(scxmlFileName));
QVERIFY(!stateMachine.isNull());