diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-05 00:51:29 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-05 00:51:29 +0200 |
| commit | da908d815787cd0272c8bdeef40e1a4d2f6a29f8 (patch) | |
| tree | 9ac2e4c326f3b4fc9cf6feb11a36970aeb8b1fad /src | |
| parent | f02a6f52ec33a4dc6f8f8b6bce9445dcd32fa11a (diff) | |
Fix confusing error on trying to load a DoM project into the player (#1948).
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_content.cc | 5 | ||||
| -rw-r--r-- | src/lib/exceptions.h | 15 | ||||
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 10 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 8 |
4 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 318e3ce52..256112eb2 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -186,10 +186,7 @@ DCPContent::read_directory (boost::filesystem::path p) if (!have_metadata) { throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?"); } else { - throw DCPError ( - "This looks like a DCP-o-matic project folder, which cannot be added to a different project. " - "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import." - ); + throw ProjectFolderError (); } } diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 05cda9659..c64f561a8 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -266,6 +266,21 @@ public: {} }; + +/** @class ProjectFolderError + * @brief An attempt has been made to read a DCP from a directory, but it looks + * like the directory actually contains a DCP-o-matic project. + */ +class ProjectFolderError : public DCPError +{ +public: + /* Code which catches this exception will provide their own message */ + ProjectFolderError () + : DCPError ("dummy") + {} +}; + + class InvalidSignerError : public std::runtime_error { public: diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 72ac93cc7..77e48ce0c 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -352,6 +352,7 @@ public: reset_film (); try { _stress.set_suspended (true); + // here auto dcp = make_shared<DCPContent>(dir); auto job = make_shared<ExamineContentJob>(_film, dcp); _examine_job_connection = job->Finished.connect(bind(&DOMFrame::add_dcp_to_film, this, weak_ptr<Job>(job), weak_ptr<Content>(dcp))); @@ -361,6 +362,15 @@ public: return; } Config::instance()->add_to_player_history (dir); + } catch (ProjectFolderError &) { + error_dialog ( + this, + wxString::Format(_("Could not load a DCP from %s"), std_to_wx(dir.string())), + _( + "This looks like a DCP-o-matic project folder, which cannot be loaded into the player. " + "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to play." + ) + ); } catch (dcp::ReadError& e) { error_dialog (this, wxString::Format(_("Could not load a DCP from %s"), std_to_wx(dir.string())), std_to_wx(e.what())); } catch (DCPError& e) { diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 7789e7b78..d1859b894 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -511,6 +511,14 @@ ContentPanel::add_dcp_clicked () try { _film->examine_and_add_content (make_shared<DCPContent>(path)); + } catch (ProjectFolderError &) { + error_dialog ( + _parent, + _( + "This looks like a DCP-o-matic project folder, which cannot be added to a different project. " + "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import." + ) + ); } catch (exception& e) { error_dialog (_parent, e.what()); } |
