From 6ca34bc1ef59dd206379f35eb940e607a59c9804 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 9 Sep 2019 00:27:23 +0100 Subject: [PATCH] Handle errors a little better when scanning for closed captions (in hints). --- src/lib/hints.cc | 26 +++++++++++++++----------- src/lib/hints.h | 2 +- src/wx/hints_dialog.cc | 6 ++++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/lib/hints.cc b/src/lib/hints.cc index cf14f0699..a9b9d6f54 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -273,20 +273,24 @@ Hints::thread () struct timeval last_pulse; gettimeofday (&last_pulse, 0); - while (!player->pass()) { - - struct timeval now; - gettimeofday (&now, 0); - if ((seconds(now) - seconds(last_pulse)) > 1) { - { - boost::mutex::scoped_lock lm (_mutex); - if (_stop) { - break; + try { + while (!player->pass()) { + + struct timeval now; + gettimeofday (&now, 0); + if ((seconds(now) - seconds(last_pulse)) > 1) { + { + boost::mutex::scoped_lock lm (_mutex); + if (_stop) { + break; + } } + emit (bind (boost::ref(Pulse))); + last_pulse = now; } - emit (bind (boost::ref(Pulse))); - last_pulse = now; } + } catch (...) { + store_current (); } emit (bind(boost::ref(Finished))); diff --git a/src/lib/hints.h b/src/lib/hints.h index 00c2486e7..e9a75fb14 100644 --- a/src/lib/hints.h +++ b/src/lib/hints.h @@ -30,7 +30,7 @@ class Film; -class Hints : public Signaller +class Hints : public Signaller, public ExceptionStore { public: explicit Hints (boost::weak_ptr film); diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index f8d03626f..cb0de450a 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -163,6 +163,12 @@ HintsDialog::pulse () void HintsDialog::finished () { + try { + _hints->rethrow (); + } catch (std::exception& e) { + error_dialog (this, wxString::Format(_("A problem occurred when looking for hints (%s)"), std_to_wx(e.what()))); + } + _finished = true; update (); _gauge->Hide (); -- 2.30.2