Cope with bad DCPs better in the editor.
authorCarl Hetherington <cth@carlh.net>
Sat, 3 Jun 2023 19:18:36 +0000 (21:18 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Jun 2023 22:48:55 +0000 (00:48 +0200)
src/tools/dcpomatic_editor.cc

index 69fbe4643a1fa2dec5be43f748685fa0c472a8d2..eb968b1e8d5cd251a65e690fec45a584f14f2a0c 100644 (file)
@@ -328,10 +328,15 @@ public:
 
        void load_dcp (boost::filesystem::path path)
        {
-               _notebook->DeleteAllPages();
+               try {
+                       _dcp = dcp::DCP(path);
+                       _dcp->read();
+               } catch (std::runtime_error& e) {
+                       error_dialog(this, _("Could not load DCP"), std_to_wx(e.what()));
+                       return;
+               }
 
-               _dcp = dcp::DCP(path);
-               _dcp->read();
+               _notebook->DeleteAllPages();
                for (auto cpl: _dcp->cpls()) {
                        _notebook->AddPage(new CPLPanel(_notebook, cpl), wx_to_std(cpl->annotation_text().get_value_or(cpl->id())));
                }