summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-05-06 11:02:22 +0300
committerAntti Määttä <antti.maatta@qt.io>2020-05-07 09:56:56 +0000
commitc179b9602ecd003c306803b757fd44203e584405 (patch)
tree54ab8e7fb62148b98c6742407696dc0a533209e2
parent7d12625223aaf52e55d7bb53946cea486cdedafa (diff)
Fix editor loading custom material images
Add project path to the custom material image path and check if the image path contains ../. Change-Id: Iab436ffa304c94cdc8235dc9fbf06abd9c060e71 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
index 1dd352c..0292428 100644
--- a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
+++ b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
@@ -125,12 +125,25 @@ void SDynamicObject::SetStrPropertyValueT(dynamic::SPropertyDefinition &inDefini
if (inProjectDir == NULL)
inProjectDir = "";
if (CFileTools::RequiresCombineBaseAndRelative(inValue)) {
- QString path = QDir(inProjectDir).cleanPath(inValue);
- 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 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());
+ }
+ }
} else {
SetPropertyValueT(inDefinition, inStrTable.RegisterStr(inValue));
// If the image path is not adjusted here, an invalid textures flashes for one frame