Provide a similar fix to the one in ff639b3cf30afcc097bfd21d39c8d15f466cadd6
[dcpomatic.git] / src / lib / dcp_examiner.cc
index 8fa41a8a59d536dfe899d9cf0bd54a75a8dfebaa..0cfe499a3234b982063e7617c4fe98405140c6d0 100644 (file)
@@ -72,12 +72,12 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
        auto cpls = dcp::find_and_resolve_cpls (content->directories(), tolerant);
 
        if (content->cpl ()) {
-               /* Use the CPL that the content was using before */
-               for (auto i: cpls) {
-                       if (i->id() == content->cpl().get()) {
-                               cpl = i;
-                       }
+               /* Use the CPL that was specified, or that the content was using before */
+               auto iter = std::find_if(cpls.begin(), cpls.end(), [content](shared_ptr<dcp::CPL> cpl) { return cpl->id() == content->cpl().get(); });
+               if (iter == cpls.end()) {
+                       throw CPLNotFoundError(content->cpl().get());
                }
+               cpl = *iter;
        } else {
                /* Choose the CPL with the fewest unsatisfied references */
 
@@ -252,6 +252,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                        _reel_lengths.push_back (i->atmos()->actual_duration());
                }
 
+               if (reel_fonts.empty()) {
+                       reel_fonts.push_back(make_shared<dcpomatic::Font>(""));
+               }
+
                _fonts.push_back(reel_fonts);
        }