X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fwx%2Fcontent_menu.cc;h=c643602bdca548828e4719145119092d1ded8ccc;hb=c2ce6455ababea2f1db9fb5d8771fa1327c2fcdb;hp=2218c5c085fe4479ff8b569c30d209c9429ccb56;hpb=260e924ce6c84d08bfc62ba458e49b53716cff6e;p=dcpomatic.git diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 2218c5c08..c643602bd 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -31,8 +31,11 @@ #include "lib/job_manager.h" #include "lib/exceptions.h" #include "lib/dcp_content.h" +#include "lib/ffmpeg_content.h" #include #include +#include +#include using std::cout; using std::vector; @@ -87,8 +90,8 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _repeat->Enable (!_content.empty ()); int n = 0; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - if (dynamic_pointer_cast (*i)) { + BOOST_FOREACH (shared_ptr i, _content) { + if (dynamic_pointer_cast (i)) { ++n; } } @@ -139,8 +142,8 @@ void ContentMenu::join () { vector > fc; - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr f = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr f = dynamic_pointer_cast (i); if (f) { fc.push_back (f); } @@ -155,8 +158,8 @@ ContentMenu::join () try { shared_ptr joined (new FFmpegContent (film, fc)); - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - film->remove_content (*i); + BOOST_FOREACH (shared_ptr i, _content) { + film->remove_content (i); } film->add_content (joined); } catch (JoinError& e) { @@ -182,8 +185,8 @@ ContentMenu::remove () /* Special case: we only remove FFmpegContent if its video view is selected; if not, and its audio view is selected, we unmap the audio. */ - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr fc = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr i, _content) { + shared_ptr fc = dynamic_pointer_cast (i); if (!fc) { continue; } @@ -191,9 +194,9 @@ ContentMenu::remove () shared_ptr video; shared_ptr audio; - for (TimelineContentViewList::iterator i = _views.begin(); i != _views.end(); ++i) { - shared_ptr v = dynamic_pointer_cast (*i); - shared_ptr a = dynamic_pointer_cast (*i); + BOOST_FOREACH (shared_ptr j, _views) { + shared_ptr v = dynamic_pointer_cast (j); + shared_ptr a = dynamic_pointer_cast (j); if (v && v->content() == fc) { video = v; } else if (a && a->content() == fc) { @@ -234,22 +237,27 @@ ContentMenu::find_missing () /* XXX: a bit nasty */ shared_ptr ic = dynamic_pointer_cast (_content.front ()); - if (ic && !ic->still ()) { + shared_ptr dc = dynamic_pointer_cast (_content.front ()); + + int r = wxID_CANCEL; + boost::filesystem::path path; + + if ((ic && !ic->still ()) || dc) { wxDirDialog* d = new wxDirDialog (0, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST); - int const r = d->ShowModal (); - if (r == wxID_OK) { - content.reset (new ImageContent (film, boost::filesystem::path (wx_to_std (d->GetPath ())))); - } + r = d->ShowModal (); + path = wx_to_std (d->GetPath ()); d->Destroy (); } else { wxFileDialog* d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE); - int const r = d->ShowModal (); - if (r == wxID_OK) { - content = content_factory (film, wx_to_std (d->GetPath ())); - } + r = d->ShowModal (); + path = wx_to_std (d->GetPath ()); d->Destroy (); } + if (r == wxID_OK) { + content = content_factory (film, path); + } + if (!content) { return; } @@ -277,8 +285,8 @@ ContentMenu::re_examine () return; } - for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { - film->examine_content (*i); + BOOST_FOREACH (shared_ptr i, _content) { + film->examine_content (i); } } @@ -317,6 +325,8 @@ ContentMenu::kdm () 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 ())); + d->Destroy (); + return; } shared_ptr film = _film.lock ();