X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_player.cc;h=112f2c0654b463ef711d414188a7cf9605f7fdac;hb=5ccfb74647db6917c054d6d67f91ed5a74e397ba;hp=72ac93cc75a48716782f2ef57c2df206607a17f5;hpb=33e13c4053138930f4b2f59349e441c76111059d;p=dcpomatic.git diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 72ac93cc7..112f2c065 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -56,6 +56,7 @@ #include "lib/ffmpeg_content.h" #include "lib/dcpomatic_log.h" #include "lib/file_log.h" +#include #include #include #include @@ -258,6 +259,14 @@ public: _stress.LoadDCP.connect (boost::bind(&DOMFrame::load_dcp, this, _1)); } + ~DOMFrame () + { + /* It's important that this is stopped before our frame starts destroying its children, + * otherwise UI elements that it depends on will disappear from under it. + */ + _viewer.reset (); + } + void setup_main_sizer (Config::PlayerMode mode) { _main_sizer->Detach (_viewer->panel()); @@ -352,6 +361,7 @@ public: reset_film (); try { _stress.set_suspended (true); + // here auto dcp = make_shared(dir); auto job = make_shared(_film, dcp); _examine_job_connection = job->Finished.connect(bind(&DOMFrame::add_dcp_to_film, this, weak_ptr(job), weak_ptr(dcp))); @@ -361,6 +371,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) { @@ -1131,8 +1150,15 @@ private: } _frame->Show (); - PlayServer* server = new PlayServer (_frame); - new thread (boost::bind (&PlayServer::run, server)); + try { + auto server = new PlayServer (_frame); + new thread (boost::bind (&PlayServer::run, server)); + } catch (std::exception& e) { + /* This is not the end of the world; probably a failure to bind the server socket + * because there's already another player running. + */ + LOG_DEBUG_PLAYER ("Failed to start play server (%1)", e.what()); + } if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) { try {