summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
index 0292428..8e927fe 100644
--- a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
+++ b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
@@ -126,24 +126,29 @@ void SDynamicObject::SetStrPropertyValueT(dynamic::SPropertyDefinition &inDefini
inProjectDir = "";
if (CFileTools::RequiresCombineBaseAndRelative(inValue)) {
QString value(QDir::cleanPath(inValue));
- QDir projectDir(inProjectDir);
- QString path = projectDir.path() + QChar('/') + value;
- if (QFileInfo(path).exists()) {
- ioWorkspace.assign(path.toLatin1().constData());
- SetPropertyValueT(inDefinition, inStrTable.RegisterStr(ioWorkspace.c_str()));
- // We also adjust the image path in the definition
- // I could not find a better place
- inDefinition.m_ImagePath = inStrTable.RegisterStr(ioWorkspace.c_str());
- } else if (value.startsWith("../")) {
- path = projectDir.path() + QChar('/') + value.right(value.size() - 3);
- if (QFileInfo(path).exists()) {
- ioWorkspace.assign(path.toLatin1().constData());
- SetPropertyValueT(inDefinition, inStrTable.RegisterStr(ioWorkspace.c_str()));
- // We also adjust the image path in the definition
- // I could not find a better place
- inDefinition.m_ImagePath = inStrTable.RegisterStr(ioWorkspace.c_str());
+ QString projectDir(inProjectDir);
+ QString path = value;
+
+ bool tryResolveRelativePath = !projectDir.startsWith(QStringLiteral(":/"));
+ if (tryResolveRelativePath)
+ path.prepend(projectDir + QChar('/'));
+
+ if (tryResolveRelativePath) {
+ bool exists = QFileInfo(path).exists();
+ if (!exists && value.startsWith("../")) {
+ QString tryPath = projectDir + QChar('/') + value.right(value.size() - 3);
+ exists = QFileInfo(tryPath).exists();
+ if (exists)
+ path = tryPath;
+ else
+ path = value; // reset back to initial value if resolve failed
}
}
+ ioWorkspace.assign(path.toLatin1().constData());
+ SetPropertyValueT(inDefinition, inStrTable.RegisterStr(ioWorkspace.c_str()));
+ // We also adjust the image path in the definition
+ // I could not find a better place
+ inDefinition.m_ImagePath = inStrTable.RegisterStr(ioWorkspace.c_str());
} else {
SetPropertyValueT(inDefinition, inStrTable.RegisterStr(inValue));
// If the image path is not adjusted here, an invalid textures flashes for one frame