diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-10-11 19:57:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-10-11 19:57:22 +0100 |
| commit | b55c6c5496f6c8248dd51bbcaecb80ef0efcbadb (patch) | |
| tree | 0ccd243f9024e9dbee99dd43672cd3f7ecb4f79a /src | |
| parent | e90a898fd817f3a419134082ce390d66925c2fa4 (diff) | |
Fix crash on opening content menu for DCPs that have had incorrect KDMs added.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_examiner.cc | 4 | ||||
| -rw-r--r-- | src/lib/film.cc | 7 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/wx/content_menu.cc | 45 | ||||
| -rw-r--r-- | src/wx/content_menu.h | 4 |
5 files changed, 37 insertions, 24 deletions
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index e25583cb6..74640ff00 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -192,10 +192,6 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content) } } catch (dcp::DCPReadError& e) { _kdm_valid = false; - if (_encrypted && content->kdm ()) { - /* XXX: maybe don't use an exception for this */ - throw runtime_error (_("The KDM does not decrypt the DCP. Perhaps it is targeted at the wrong CPL.")); - } } DCPOMATIC_ASSERT (cpl->standard ()); diff --git a/src/lib/film.cc b/src/lib/film.cc index 13a03d929..1a1957d33 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1028,13 +1028,6 @@ Film::content () const } void -Film::examine_content (shared_ptr<Content> c) -{ - shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); - JobManager::instance()->add (j); -} - -void Film::examine_and_add_content (shared_ptr<Content> c) { if (dynamic_pointer_cast<FFmpegContent> (c) && _directory) { diff --git a/src/lib/film.h b/src/lib/film.h index 5fa35b065..ad94852a2 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -289,7 +289,6 @@ public: void set_directory (boost::filesystem::path); void set_name (std::string); void set_use_isdcf_name (bool); - void examine_content (boost::shared_ptr<Content>); void examine_and_add_content (boost::shared_ptr<Content>); void add_content (boost::shared_ptr<Content>); void remove_content (boost::shared_ptr<Content>); diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index a96461c30..ad6d6fc65 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -94,6 +94,10 @@ ContentMenu::ContentMenu (wxWindow* p) ContentMenu::~ContentMenu () { delete _menu; + + BOOST_FOREACH (boost::signals2::connection& i, _job_connections) { + i.disconnect (); + } } void @@ -306,13 +310,15 @@ ContentMenu::find_missing () shared_ptr<Job> j (new ExamineContentJob (film, content)); - _job_connection = j->Finished.connect ( - bind ( - &ContentMenu::maybe_found_missing, - this, - boost::weak_ptr<Job> (j), - boost::weak_ptr<Content> (_content.front ()), - boost::weak_ptr<Content> (content) + _job_connections.push_back ( + j->Finished.connect ( + bind ( + &ContentMenu::maybe_found_missing, + this, + boost::weak_ptr<Job> (j), + boost::weak_ptr<Content> (_content.front ()), + boost::weak_ptr<Content> (content) + ) ) ); @@ -328,7 +334,7 @@ ContentMenu::re_examine () } BOOST_FOREACH (shared_ptr<Content> i, _content) { - film->examine_content (i); + JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, i))); } } @@ -373,13 +379,30 @@ ContentMenu::kdm () shared_ptr<Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - film->examine_content (dcp); + shared_ptr<Job> j (new ExamineContentJob (film, dcp)); + _job_connections.push_back ( + j->Finished.connect (bind (&ContentMenu::check_kdm_validity, this, weak_ptr<DCPContent> (dcp))) + ); + JobManager::instance()->add (j); } d->Destroy (); } void +ContentMenu::check_kdm_validity (weak_ptr<DCPContent> wp) +{ + shared_ptr<DCPContent> dcp = wp.lock (); + if (!dcp) { + return; + } + + if (dcp->needs_kdm ()) { + error_dialog (0, _("The KDM does not decrypt the DCP. Perhaps it is targeted at the wrong CPL.")); + } +} + +void ContentMenu::ov () { DCPOMATIC_ASSERT (!_content.empty ()); @@ -392,7 +415,7 @@ ContentMenu::ov () dcp->add_ov (wx_to_std (d->GetPath ())); shared_ptr<Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - film->examine_content (dcp); + JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp))); } d->Destroy (); @@ -425,5 +448,5 @@ ContentMenu::cpl_selected (wxCommandEvent& ev) dcp->set_cpl ((*i)->id ()); shared_ptr<Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - film->examine_content (dcp); + JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp))); } diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h index 43480888a..7b1e663fa 100644 --- a/src/wx/content_menu.h +++ b/src/wx/content_menu.h @@ -29,6 +29,7 @@ class Film; class Job; +class DCPContent; class ContentMenu : public boost::noncopyable { @@ -49,6 +50,7 @@ private: void remove (); void maybe_found_missing (boost::weak_ptr<Job>, boost::weak_ptr<Content>, boost::weak_ptr<Content>); void cpl_selected (wxCommandEvent& ev); + void check_kdm_validity (boost::weak_ptr<DCPContent> wp); wxMenu* _menu; wxMenu* _cpl_menu; @@ -67,7 +69,7 @@ private: wxMenuItem* _choose_cpl; wxMenuItem* _remove; - boost::signals2::scoped_connection _job_connection; + std::list<boost::signals2::connection> _job_connections; }; #endif |
