summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-05-28 02:12:39 +0200
committerCarl Hetherington <cth@carlh.net>2023-05-28 20:55:30 +0200
commit970c75b75f9acc5dad4f3df10938687552b57874 (patch)
tree62d10d326001bc672a8f8ac112da4cd8fab96788 /src
parentaf8a3bcc86e89afac79ee6bda3fea811f25f3cc8 (diff)
Don't unconditionally clear _fonts when inspecting assets (DoM #2536).v1.8.70
resolve_fonts() is sometimes called for the same asset with different lists of things to check. If it is called first with a font, and then without one, we want to keep the font from the first call.
Diffstat (limited to 'src')
-rw-r--r--src/interop_subtitle_asset.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index 0116c11c..d0c80f5e 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -230,8 +230,6 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
void
InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets)
{
- _fonts.clear();
-
for (auto asset: assets) {
auto font = dynamic_pointer_cast<FontAsset>(asset);
if (!font) {
@@ -243,7 +241,12 @@ InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets)
for (auto load_font_node: _load_font_nodes) {
auto const path_in_load_font_node = _file->parent_path() / load_font_node->uri;
if (font->file() && path_in_load_font_node == *font->file()) {
- _fonts.push_back(Font(load_font_node->id, asset->id(), font->file().get()));
+ auto existing = std::find_if(_fonts.begin(), _fonts.end(), [load_font_node](Font const& font) { return font.load_id == load_font_node->id; });
+ if (existing != _fonts.end()) {
+ *existing = Font(load_font_node->id, asset->id(), font->file().get());
+ } else {
+ _fonts.push_back(Font(load_font_node->id, asset->id(), font->file().get()));
+ }
}
}
}