X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftext_panel.cc;h=805af2c238fa727dcc5fd4495bce235e0151c6d9;hb=e87f943433216d294b22853411eca5c582be1066;hp=1d2c8663135f748a34403d1d8c80aaeeab3162fd;hpb=2a788386131d7f813dd71e506050b2de956ba567;p=dcpomatic.git diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index 1d2c86631..805af2c23 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -32,7 +32,6 @@ #include "subtitle_appearance_dialog.h" #include "text_panel.h" #include "text_view.h" -#include "wx_ptr.h" #include "wx_util.h" #include "lib/analyse_subtitles_job.h" #include "lib/dcp_content.h" @@ -61,6 +60,9 @@ using std::string; using std::vector; using boost::bind; using boost::optional; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif /** @param t Original text type of the content, if known */ @@ -826,13 +828,13 @@ TextPanel::try_to_load_analysis () if (!boost::filesystem::exists(path)) { for (auto i: JobManager::instance()->get()) { - if (dynamic_pointer_cast(i)) { + if (dynamic_pointer_cast(i) && !i->finished()) { i->cancel (); } } JobManager::instance()->analyse_subtitles ( - _parent->film(), content, _analysis_finished_connection, bind(&TextPanel::analysis_finished, this) + _parent->film(), content, _analysis_finished_connection, bind(&TextPanel::analysis_finished, this, _1) ); return; } @@ -842,10 +844,10 @@ TextPanel::try_to_load_analysis () } catch (OldFormatError& e) { /* An old analysis file: recreate it */ JobManager::instance()->analyse_subtitles ( - _parent->film(), content, _analysis_finished_connection, bind(&TextPanel::analysis_finished, this) + _parent->film(), content, _analysis_finished_connection, bind(&TextPanel::analysis_finished, this, _1) ); return; - } + } update_outline_subtitles_in_viewer (); } @@ -884,27 +886,25 @@ TextPanel::clear_outline_subtitles () void -TextPanel::analysis_finished () +TextPanel::analysis_finished(Job::Result result) { + _loading_analysis = false; + auto content = _analysis_content.lock (); - if (!content) { - _loading_analysis = false; - setup_sensitivity (); + if (!content || result == Job::Result::RESULT_CANCELLED) { + clear_outline_subtitles(); + setup_sensitivity(); return; } if (!boost::filesystem::exists(_parent->film()->subtitle_analysis_path(content))) { - /* We analysed and still nothing showed up, so maybe it was cancelled or it failed. - Give up. - */ + /* We analysed and still nothing showed up, so maybe it failed. Give up. */ error_dialog (_parent->window(), _("Could not analyse subtitles.")); clear_outline_subtitles (); - _loading_analysis = false; setup_sensitivity (); return; } - _loading_analysis = false; try_to_load_analysis (); }