diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-01 21:48:49 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-07 22:49:28 +0100 |
| commit | a8ef2587872ef51748f7e9e14f550770408880e1 (patch) | |
| tree | cc2acb3f04196075cec18f7f2da460247ced07a1 | |
| parent | 8cfbd33752a6b3989f66f4439759ba2d031902ad (diff) | |
Don't write the same asset more than once to an ASSETMAP.multi-fonts-in-pkl
| -rw-r--r-- | src/asset_map.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/asset_map.cc b/src/asset_map.cc index c1bafd92..615e1f5e 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -112,7 +112,13 @@ AssetMap::Asset::Asset(cxml::ConstNodePtr node, boost::filesystem::path root, dc void AssetMap::add_asset(string id, boost::filesystem::path path, bool pkl) { - _assets.push_back(Asset(id, path, pkl)); + auto iter = std::find_if(_assets.begin(), _assets.end(), [id](Asset const& a) { return a.id() == id; }); + if (iter == _assets.end()) { + _assets.push_back(Asset(id, path, pkl)); + } else { + /* We already have this asset, so let's hope it's actually the same one */ + DCP_ASSERT(iter->path() == path); + } } |
