From f8a6ce7ef5cc7e52aa10a6a133b4e628f3d2a50d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 9 Jun 2024 23:38:24 +0200 Subject: 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. --- src/lib/dcp_content.cc | 5 +++++ test/subtitle_font_id_test.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) 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(film->dir(film->dcp_name())); + auto film2 = new_test_film(name + "_film2", { dcp }); + film2->write_metadata(); + + auto film3 = std::make_shared(film2->dir(".")); + film3->read_metadata(); + BOOST_REQUIRE(!film3->content().empty()); + auto check_dcp = std::dynamic_pointer_cast(film3->content()[0]); + BOOST_REQUIRE(check_dcp); + + check_dcp->check_font_ids(); +} + -- cgit v1.2.3