Don't write duplicate <LoadFont> nodes into subtitle files.
authorCarl Hetherington <cth@carlh.net>
Sun, 21 Feb 2016 19:19:34 +0000 (19:19 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 21 Feb 2016 19:19:34 +0000 (19:19 +0000)
ChangeLog
src/lib/writer.cc
test/data
test/xml_subtitle_test.cc

index dc5c28c11282293d2bf742c38027c9584f6ed360..7f16414c96dfbf5d44da8c5374cb8842cd5a9497 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-21  Carl Hetherington  <cth@carlh.net>
+
+       * Fix duplicate <LoadFont> nodes in subtitle files.
+
 2016-02-18  c.hetherington  <cth@carlh.net>
 
        * Add some more information to the content properties
index 47c6b838142619a355cab1f0fbc298f84586df9b..ea8a2e89f821341666a46267a5c2918595c8cac7 100644 (file)
@@ -543,8 +543,20 @@ Writer::write (PlayerSubtitles subs)
 void
 Writer::write (list<shared_ptr<Font> > fonts)
 {
-       /* Just keep a list of fonts and we'll deal with them in ::finish */
-       copy (fonts.begin (), fonts.end (), back_inserter (_fonts));
+       /* Just keep a list of unique fonts and we'll deal with them in ::finish */
+
+       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
+               bool got = false;
+               BOOST_FOREACH (shared_ptr<Font> j, _fonts) {
+                       if (*i == *j) {
+                               got = true;
+                       }
+               }
+
+               if (!got) {
+                       _fonts.push_back (i);
+               }
+       }
 }
 
 bool
index b4b0f4e1ef3e0afac12d82d2c6c04ce39ea2f6ff..be07663c918efc93e32b6344d533974a16a9b9f4 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit b4b0f4e1ef3e0afac12d82d2c6c04ce39ea2f6ff
+Subproject commit be07663c918efc93e32b6344d533974a16a9b9f4
index 554591b9213b20be703b9050003ef20f8087dcb7..4e0dcf8aee64240ec1a48fa09bd48ccf5b1ce7ca 100644 (file)
@@ -50,3 +50,24 @@ BOOST_AUTO_TEST_CASE (xml_subtitle_test)
        /* Should be blank video with MXF subtitles */
        check_dcp ("test/data/xml_subtitle_test", film->dir (film->dcp_name ()));
 }
+
+/** Check the subtitle XML when there are two subtitle files in the project */
+BOOST_AUTO_TEST_CASE (xml_subtitle_test2)
+{
+       shared_ptr<Film> film = new_test_film ("xml_subtitle_test2");
+       film->set_container (Ratio::from_id ("185"));
+       film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+       film->set_name ("frobozz");
+       film->set_interop (true);
+       shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, "test/data/subrip2.srt"));
+       content->set_use_subtitles (true);
+       content->set_burn_subtitles (false);
+       film->examine_and_add_content (content);
+       film->examine_and_add_content (content);
+       wait_for_jobs ();
+       film->make_dcp ();
+       wait_for_jobs ();
+       film->write_metadata ();
+
+       check_dcp ("test/data/xml_subtitle_test2", film->dir (film->dcp_name ()));
+}