Don't let the meta info disappear into the void (closes #1876)

This commit is contained in:
Alexander Bock
2022-02-10 22:24:59 +01:00
parent 72110be88c
commit d3c2ee2fe5
2 changed files with 14 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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<std::string>());
// 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<std::string> ids = asset->metaInformation()->identifiers;
meta.identifiers.insert(meta.identifiers.end(), ids.begin(), ids.end());
}
asset->setMetaInformation(std::move(meta));
}