Catch exceptions when loading KDMs.
authorCarl Hetherington <cth@carlh.net>
Sun, 26 Jul 2015 18:09:36 +0000 (19:09 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 26 Jul 2015 18:09:36 +0000 (19:09 +0100)
src/wx/content_menu.cc

index 0adbc775a9134810e9db50ec4b1b4cb9f08a96f7..2218c5c085fe4479ff8b569c30d209c9429ccb56 100644 (file)
@@ -36,6 +36,7 @@
 
 using std::cout;
 using std::vector;
+using std::exception;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -312,7 +313,12 @@ ContentMenu::kdm ()
        wxFileDialog* d = new wxFileDialog (_parent, _("Select KDM"));
 
        if (d->ShowModal() == wxID_OK) {
-               dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+               try {
+                       dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+               } catch (exception& e) {
+                       error_dialog (_parent, wxString::Format (_("Could not load KDM (%s)"), e.what ()));
+               }
+
                shared_ptr<Film> film = _film.lock ();
                DCPOMATIC_ASSERT (film);
                film->examine_content (dcp);