diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-08-16 10:21:48 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-08-16 12:43:36 +0000 |
commit | 87579a5c2efc37c56642cbbf39fd7d1b7734cf1c (patch) | |
tree | 5b31de33b00112c1e3b64bc22e98b74e54ce7a63 /src/runtime/q3dsuippresentation.cpp | |
parent | 337d0ff33aa72489a199587e1abfab975c5d59f7 (diff) |
Improve Image sourcepath (re-)resolving
Make sure the value of sourcepath is re-evaluated and adjusted as needed
whenever it changes. In addition, add support for qrc:/ prefixes since
applications written for the old runtime may try to treat the values are
URLs instead of actual filenames (which is very wrong but it does not cost
much to convert qrc:/ to :/ )
Task-number: QT3DS-2089
Change-Id: Id2ba31ef6246db2d4477a87ec15433b17bc836be
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/runtime/q3dsuippresentation.cpp')
-rw-r--r-- | src/runtime/q3dsuippresentation.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp index 5bb4e73..23f3c05 100644 --- a/src/runtime/q3dsuippresentation.cpp +++ b/src/runtime/q3dsuippresentation.cpp @@ -1537,6 +1537,16 @@ void Q3DSImage::applyPropertyChanges(const Q3DSPropertyChangeList &changeList) calculateTextureTransform(); } +int Q3DSImage::mapChangeFlags(const Q3DSPropertyChangeList &changeList) +{ + int changeFlags = Q3DSGraphObject::mapChangeFlags(changeList); + for (auto it = changeList.cbegin(), itEnd = changeList.cend(); it != itEnd; ++it) { + if (it->nameStr() == QStringLiteral("sourcepath")) + changeFlags |= SourceChanges; + } + return changeFlags; +} + void Q3DSImage::resolveReferences(Q3DSUipPresentation &presentation) { if (!m_sourcePath.isEmpty()) { @@ -3934,6 +3944,12 @@ QString Q3DSUipPresentation::assetFileName(const QString &xmlFileNameRef, int *p if (rawName.startsWith(QStringLiteral("./"))) rawName = rawName.mid(2); + // workaround for confused users of the QML API trying to pass an URL + // starting with qrc:/ instead of a normal string with a filename where :/ + // is the only valid option + if (rawName.startsWith(QStringLiteral("qrc:/"))) + rawName = rawName.mid(3); + if (QFileInfo(rawName).isAbsolute()) return rawName; |