summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-05-13 21:50:06 +0100
committerCarl Hetherington <cth@carlh.net>2017-05-13 21:50:06 +0100
commit320c20b9538c985005dc850d685eecfc1a5edc98 (patch)
tree52f416fe4b5e5a1471abb44769c6668d0197069b
parentb37249ba5db6bd08fdfe340cec923130ee4cc7b9 (diff)
Give a slightly better error whn trying to add a KDM using add-file (#1035).
-rw-r--r--src/lib/content_factory.cc5
-rw-r--r--src/lib/exceptions.cc4
-rw-r--r--src/lib/exceptions.h6
-rw-r--r--src/wx/content_panel.cc10
4 files changed, 22 insertions, 3 deletions
diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc
index 87f4e36a0..e5e73f890 100644
--- a/src/lib/content_factory.cc
+++ b/src/lib/content_factory.cc
@@ -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));
diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc
index 4590531b7..cf3708896 100644
--- a/src/lib/exceptions.cc
+++ b/src/lib/exceptions.cc
@@ -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\"."))
+{}
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h
index c2f82e15b..c1b1aef4b 100644
--- a/src/lib/exceptions.h
+++ b/src/lib/exceptions.h
@@ -252,4 +252,10 @@ public:
{}
};
+class KDMAsContentError : public std::runtime_error
+{
+public:
+ KDMAsContentError ();
+};
+
#endif
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 7b6979163..446bf1121 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -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());
}
}