Prevent DCP::assets() from returning duplicates. combine
authorCarl Hetherington <cth@carlh.net>
Thu, 17 Sep 2020 12:00:21 +0000 (14:00 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 17 Sep 2020 21:07:19 +0000 (23:07 +0200)
src/dcp.cc

index b7a0da8b4f4fa20bbc152e21ef19f516844f7c00..bf8366f3dd97288b598b34f8aa6c7a7fd8538356 100644 (file)
@@ -507,12 +507,23 @@ DCP::assets (bool ignore_unresolved) const
                        if (ignore_unresolved && !j->asset_ref().resolved()) {
                                continue;
                        }
-                       shared_ptr<Asset> o = j->asset_ref().asset ();
-                       assets.push_back (o);
-                       /* More Interop special-casing */
-                       shared_ptr<InteropSubtitleAsset> sub = dynamic_pointer_cast<InteropSubtitleAsset> (o);
-                       if (sub) {
-                               sub->add_font_assets (assets);
+
+                       string const id = j->asset_ref().id();
+                       bool already_got = false;
+                       BOOST_FOREACH (shared_ptr<Asset> k, assets) {
+                               if (k->id() == id) {
+                                       already_got = true;
+                               }
+                       }
+
+                       if (!already_got) {
+                               shared_ptr<Asset> o = j->asset_ref().asset();
+                               assets.push_back (o);
+                               /* More Interop special-casing */
+                               shared_ptr<InteropSubtitleAsset> sub = dynamic_pointer_cast<InteropSubtitleAsset> (o);
+                               if (sub) {
+                                       sub->add_font_assets (assets);
+                               }
                        }
                }
        }