diff --git a/src/scene/asset.cpp b/src/scene/asset.cpp index a90ddbafe6..fbfcff7fb8 100644 --- a/src/scene/asset.cpp +++ b/src/scene/asset.cpp @@ -206,9 +206,11 @@ void Asset::startSynchronizations() { } void Asset::addIdentifier(std::string identifier) { - if (_metaInformation.has_value()) { - _metaInformation->identifiers.push_back(std::move(identifier)); + if (!_metaInformation.has_value()) { + _metaInformation = MetaInformation(); } + + _metaInformation->identifiers.push_back(std::move(identifier)); } void Asset::load(Asset* parent) { diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index f5bb5804d1..50e8468340 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -351,6 +351,16 @@ bool AssetManager::loadAsset(Asset* asset, Asset* parent) { meta.url = p.url.value_or(""); meta.license = p.license.value_or(""); meta.identifiers = p.identifiers.value_or(std::vector()); + + // We need to do this as the asset might have 'export'ed identifiers before + // defining the meta table. Therefore the meta information already contains some + // identifiers that we don't want to throw away + if (asset->metaInformation().has_value() && + !asset->metaInformation()->identifiers.empty()) + { + std::vector ids = asset->metaInformation()->identifiers; + meta.identifiers.insert(meta.identifiers.end(), ids.begin(), ids.end()); + } asset->setMetaInformation(std::move(meta)); }