From 018bb01d2190cb57ded144fcb3944c3312abbbba Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 27 Sep 2020 20:20:23 +0200 Subject: [PATCH] is optional in Interop so we can't assume it's there. --- src/cpl.cc | 7 +++++-- src/cpl.h | 2 +- test/write_subtitle_test.cc | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cpl.cc b/src/cpl.cc index ead592fd..2768e797 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -654,10 +654,13 @@ CPL::set_content_versions (vector v) } -ContentVersion +optional CPL::content_version () const { - DCP_ASSERT (!_content_versions.empty()); + if (_content_versions.empty()) { + return optional(); + } + return _content_versions[0]; } diff --git a/src/cpl.h b/src/cpl.h index 72366ee3..c1f505df 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -140,7 +140,7 @@ public: return _content_kind; } - ContentVersion content_version () const; + boost::optional content_version () const; std::vector content_versions () const { return _content_versions; diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc index b7d8119a..4bdc6e9d 100644 --- a/test/write_subtitle_test.cc +++ b/test/write_subtitle_test.cc @@ -46,6 +46,7 @@ using std::list; using std::string; +using boost::optional; using boost::shared_ptr; /** Test dcp::order::Font::take_intersection */ @@ -372,9 +373,10 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3) cpl->set_creator (creator); cpl->set_issue_date (issue_date); cpl->set_annotation_text (annotation_text); - dcp::ContentVersion cv = cpl->content_version(); - cv.label_text = "foo"; - cpl->set_content_version (cv); + optional cv = cpl->content_version(); + BOOST_REQUIRE (cv); + cv->label_text = "foo"; + cpl->set_content_version (*cv); dcp::DCP dcp ("build/test/write_interop_subtitle_test3"); dcp.add (cpl); -- 2.30.2