Give a slightly better error whn trying to add a KDM using add-file (#1035).
[dcpomatic.git] / src / wx / content_panel.cc
index 1d748be5ff2d820becaaf50189f0470199fcd1a1..446bf11218335ba40c102b120d706cd694365b61 100644 (file)
@@ -270,7 +270,7 @@ ContentPanel::add_file_clicked ()
        /* This method is also called when Ctrl-A is pressed, so check that our notebook page
           is visible.
        */
-       if (_parent->GetCurrentPage() != _panel) {
+       if (_parent->GetCurrentPage() != _panel || !_film) {
                return;
        }
 
@@ -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());
        }
 }