Give a slightly better error whn trying to add a KDM using add-file (#1035).
authorCarl Hetherington <cth@carlh.net>
Sat, 13 May 2017 20:50:06 +0000 (21:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 13 May 2017 20:50:06 +0000 (21:50 +0100)
src/lib/content_factory.cc
src/lib/exceptions.cc
src/lib/exceptions.h
src/wx/content_panel.cc

index 87f4e36a0402ddae1f2d0c3928fbaebce9924ae8..e5e73f890b8592e9ca6df33af21056f2830d8608 100644 (file)
@@ -170,6 +170,11 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
                } else if (ext == ".srt" || ext == ".ssa" || ext == ".ass") {
                        single.reset (new TextSubtitleContent (film, path));
                } else if (ext == ".xml") {
+                       cxml::Document doc;
+                       doc.read_file (path);
+                       if (doc.root_name() == "DCinemaSecurityMessage") {
+                               throw KDMAsContentError ();
+                       }
                        single.reset (new DCPSubtitleContent (film, path));
                } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) {
                        single.reset (new DCPSubtitleContent (film, path));
index 4590531b7bd5a8cabe73d70650dd5b96467083bd..cf3708896cbc12ed9ce15a8ca6a938925607c9c7 100644 (file)
@@ -86,3 +86,7 @@ ProgrammingError::ProgrammingError (string file, int line)
 {
 
 }
+
+KDMAsContentError::KDMAsContentError ()
+       : runtime_error (_("This file is a KDM.  KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\"."))
+{}
index c2f82e15ba5315bca041b63bd925b4c164f2d658..c1b1aef4b0a61a11ef36ffbae4d928e59cda5f03 100644 (file)
@@ -252,4 +252,10 @@ public:
        {}
 };
 
+class KDMAsContentError : public std::runtime_error
+{
+public:
+       KDMAsContentError ();
+};
+
 #endif
index 7b69791634478f27277c1d7d5c0b8a09a3b4dce3..446bf11218335ba40c102b120d706cd694365b61 100644 (file)
@@ -612,9 +612,13 @@ ContentPanel::add_files (list<boost::filesystem::path> paths)
 
        /* XXX: check for lots of files here and do something */
 
-       BOOST_FOREACH (boost::filesystem::path i, paths) {
-               BOOST_FOREACH (shared_ptr<Content> j, content_factory (_film, i)) {
-                       _film->examine_and_add_content (j);
+       try {
+               BOOST_FOREACH (boost::filesystem::path i, paths) {
+                       BOOST_FOREACH (shared_ptr<Content> j, content_factory (_film, i)) {
+                               _film->examine_and_add_content (j);
+                       }
                }
+       } catch (exception& e) {
+               error_dialog (_parent, e.what());
        }
 }