summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-08-17 15:55:54 +0200
committerUlf Hermann <ulf.hermann@qt.io>2017-08-17 15:01:05 +0000
commita1dff1a11ad303a1f82f181e6386194de90ec08f (patch)
tree7379184df019452a83cafa25e261b71f3b7b13cd
parent5a4550879d30d1897e9b62e4fb73e7392c4182b8 (diff)
Properly convert URLs to local files in QML state machine loader
toString() doesn't do what we're looking for. "file:" URLs can be readily converted to local files, "qrc:" URLs can be converted by prepending a ":" to their path component. All others cannot. In order to support those, we'd have to extend QScxmlCompiler to accept generic URLs rather than file names, and then we still might not be able to actually resolve relative file names from <invoke> tags. Change-Id: I138318e8abd87e6e097445f77148668439ff980c Task-number: QTBUG-62178 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r--src/imports/scxmlstatemachine/statemachineloader.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/imports/scxmlstatemachine/statemachineloader.cpp b/src/imports/scxmlstatemachine/statemachineloader.cpp
index 946988f..0d28e6c 100644
--- a/src/imports/scxmlstatemachine/statemachineloader.cpp
+++ b/src/imports/scxmlstatemachine/statemachineloader.cpp
@@ -163,7 +163,18 @@ bool QScxmlStateMachineLoader::parse(const QUrl &source)
return false;
}
- m_stateMachine = QScxmlStateMachine::fromData(&buf, source.toString());
+ QString fileName;
+ if (source.isLocalFile()) {
+ fileName = source.toLocalFile();
+ } else if (source.scheme() == QStringLiteral("qrc")) {
+ fileName = ":" + source.path();
+ } else {
+ qmlWarning(this) << QStringLiteral("%1 is neither a local nor a resource URL.")
+ .arg(source.url())
+ << QStringLiteral("Invoking services by relative path will not work.");
+ }
+
+ m_stateMachine = QScxmlStateMachine::fromData(&buf, fileName);
m_stateMachine->setParent(this);
m_implicitDataModel = m_stateMachine->dataModel();