summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-09 23:38:24 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-09 23:38:24 +0200
commitf8a6ce7ef5cc7e52aa10a6a133b4e628f3d2a50d (patch)
treeadb47e7e84afe06d385a9bc1b5aeca6bc330ba49
parent530e62b470df2a0ab9b6173f18d87ae85c499234 (diff)
Fix an erroneous font ID error that can happen when loading projects from builds without release version tags.
So that last_written_by_earlier_than() always returns true, check_font_ids() happens when it doesn't really need to.
-rw-r--r--src/lib/dcp_content.cc5
-rw-r--r--test/subtitle_font_id_test.cc30
2 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index bbe90d1a4..0aeb1d041 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -851,6 +851,11 @@ DCPContent::check_font_ids()
return;
}
+ /* This might be called on a TextContent that already has the correct fonts
+ * (e.g. if run from a build with a LastWrittenBy containing only a git hash)
+ * so we'll get an error if we don't clear them out first.
+ */
+ text[0]->clear_fonts();
DCPExaminer examiner(shared_from_this(), true);
examiner.add_fonts(text[0]);
}
diff --git a/test/subtitle_font_id_test.cc b/test/subtitle_font_id_test.cc
index 1a4672cfe..a93145163 100644
--- a/test/subtitle_font_id_test.cc
+++ b/test/subtitle_font_id_test.cc
@@ -19,6 +19,7 @@
*/
+#include "lib/check_content_job.h"
#include "lib/content_factory.h"
#include "lib/dcp_content.h"
#include "lib/film.h"
@@ -302,3 +303,32 @@ BOOST_AUTO_TEST_CASE(no_error_with_ccap_that_mentions_no_font)
while (!player.pass()) {}
}
+
+BOOST_AUTO_TEST_CASE(subtitle_font_ids_survive_project_save)
+{
+ std::string const name = "subtitle_font_ids_survive_project_save";
+
+ auto subs = content_factory("test/data/short.srt")[0];
+ auto film = new_test_film(name + "_film", { subs });
+ film->set_interop(false);
+ make_and_verify_dcp(
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA
+ });
+
+ auto dcp = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
+ auto film2 = new_test_film(name + "_film2", { dcp });
+ film2->write_metadata();
+
+ auto film3 = std::make_shared<Film>(film2->dir("."));
+ film3->read_metadata();
+ BOOST_REQUIRE(!film3->content().empty());
+ auto check_dcp = std::dynamic_pointer_cast<DCPContent>(film3->content()[0]);
+ BOOST_REQUIRE(check_dcp);
+
+ check_dcp->check_font_ids();
+}
+