diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-11-28 14:40:28 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-11-29 08:50:15 +0000 |
commit | 3b52a1f11e2d676f12657cc976a07abea1e7ea6c (patch) | |
tree | 5d47e06bdf47bf111653dcf6d3ef8d717e47de2a /src/Authoring/Studio/Palettes/Inspector | |
parent | f7e4abcb429d17d7a1d24fb862ee116395136700 (diff) |
Fix crash when no texture selected for a texture sampler
Task-number: QT3DS-2748
Change-Id: Ida98b12bac43be0e85b0e99fb5ee797049768a4e
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector')
-rw-r--r-- | src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp index 54ff310b..32ba2bdb 100644 --- a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp @@ -90,18 +90,21 @@ int TextureChooserView::instance() const QString TextureChooserView::currentDataModelPath() const { + QString cleanPath; const auto doc = g_StudioApp.GetCore()->GetDoc(); const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem(); qt3dsdm::SValue value; propertySystem->GetInstancePropertyValue(m_instance, m_handle, value); - QString cleanPath = qt3dsdm::get<QString>(value); - if (cleanPath.isEmpty() || cleanPath == QLatin1String("./")) { + const QString currentValue = qt3dsdm::get<QString>(value); + // An empty value can sometimes be represented by a relative path either to project root or the + // presentation file, such as"./" or "../", so let's just consider all directory paths as empty + if (currentValue.isEmpty() || QFileInfo(currentValue).isDir()) { cleanPath = ChooserModelBase::noneString(); } else { cleanPath = QDir::cleanPath(QDir(doc->GetDocumentDirectory().toQString()) - .filePath(cleanPath)); + .filePath(currentValue)); } return cleanPath; } |