summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2020-09-25 08:09:12 +0300
committerTomi Korpipaa <tomi.korpipaa@qt.io>2020-09-28 08:57:38 +0300
commit188cfb0ad684f21f90ca11cdba1845c4fa97353a (patch)
tree30a3f4a269ff0b5cf6ab3af4c59d4c79da155dd1
parent03fbc3affe36cec1f12accc3971f24e6291747c6 (diff)
Prevent duplicates in searchPaths and reverse it
The first 3 paths in the searchPaths are for finding the other things we need to search for, the last ones are for source paths. Reversing the order drops the required search count in a usual case from 4 attempts to 1 or 2. Task-number: QT3DS-4172 Change-Id: I0d7665566be6b8a9d5e7b918f7596f70126ad958 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
-rw-r--r--src/runtime/Qt3DSApplication.cpp7
-rw-r--r--src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp9
2 files changed, 9 insertions, 7 deletions
diff --git a/src/runtime/Qt3DSApplication.cpp b/src/runtime/Qt3DSApplication.cpp
index 5c6dbb7..db5d359 100644
--- a/src/runtime/Qt3DSApplication.cpp
+++ b/src/runtime/Qt3DSApplication.cpp
@@ -2267,9 +2267,10 @@ bool AssetHandlers::handlePresentation(SApp &app, SAssetValue &asset, bool initI
CFileTools::CombineBaseAndRelative(app.GetProjectDirectory().c_str(),
asset.GetSource(), thePathStr);
- QDir::addSearchPath(QStringLiteral("qt3dstudio"),
- QFileInfo(QString(thePathStr.c_str()))
- .absoluteDir().absolutePath());
+ const QString absPath = QFileInfo(QString(thePathStr.c_str())).absoluteDir().absolutePath();
+ if (!QDir::searchPaths(QStringLiteral("qt3dstudio")).contains(absPath))
+ QDir::addSearchPath(QStringLiteral("qt3dstudio"), absPath);
+
SPresentationAsset &thePresentationAsset
= *asset.getDataPtr<SPresentationAsset>();
eastl::vector<SElementAttributeReference> theUIPReferences;
diff --git a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
index 87fe54c..6a0fdff 100644
--- a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
+++ b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
@@ -61,12 +61,14 @@ static const QString QT3DSTUDIO_TAG = QStringLiteral("qt3dstudio");
static QFileInfo matchCaseInsensitiveFile(const QString& file)
{
- const auto searchFromPaths = [](QString file) -> QFileInfo {
+ QStringList searchDirectories = QDir::searchPaths(QT3DSTUDIO_TAG);
+ std::reverse(searchDirectories.begin(), searchDirectories.end());
+
+ const auto searchFromPaths = [searchDirectories](QString file) -> QFileInfo {
QFileInfo fileInfo(file);
if (fileInfo.exists())
return fileInfo;
- const QStringList searchDirectories = QDir::searchPaths(QT3DSTUDIO_TAG);
for (const auto &directoryPath : searchDirectories) {
auto path = QDir::cleanPath(directoryPath + '/' + file);
QFileInfo info(path);
@@ -203,6 +205,7 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK
}
// First check ktx files if preferKtx is set
+ QString result;
if (preferKtx) {
QString ktxSource = path;
const bool originalIsKtx = path.endsWith(QLatin1String("ktx"), Qt::CaseInsensitive);
@@ -211,7 +214,6 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK
ktxSource = ktxSource.left(index);
ktxSource.append(QLatin1String(".ktx"));
}
- QString result;
if (checkFileExists(ktxSource, relative, result))
return result;
if (originalIsKtx) {
@@ -220,7 +222,6 @@ QString IBufferManager::resolveImagePath(const QString &sourcePath, bool preferK
}
}
- QString result;
if (checkFileExists(path, relative, result))
return result;