Handle errors a little better when scanning for closed captions (in hints).
authorCarl Hetherington <cth@carlh.net>
Sun, 8 Sep 2019 23:27:23 +0000 (00:27 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 8 Sep 2019 23:27:23 +0000 (00:27 +0100)
src/lib/hints.cc
src/lib/hints.h
src/wx/hints_dialog.cc

index cf14f0699a299a117108c9ec585d725f6faf1e51..a9b9d6f54b34562b8bd6858edeac8c12ce8e66c5 100644 (file)
@@ -273,20 +273,24 @@ Hints::thread ()
        struct timeval last_pulse;
        gettimeofday (&last_pulse, 0);
 
        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)));
        }
 
        emit (bind(boost::ref(Finished)));
index 00c2486e7e430e094ab1fcbdfc5def77cb70c29f..e9a75fb14dabc17664d2451ca8bf5c9d71cae479 100644 (file)
@@ -30,7 +30,7 @@
 
 class Film;
 
 
 class Film;
 
-class Hints : public Signaller
+class Hints : public Signaller, public ExceptionStore
 {
 public:
        explicit Hints (boost::weak_ptr<const Film> film);
 {
 public:
        explicit Hints (boost::weak_ptr<const Film> film);
index f8d03626fe06459195362566d810e71b4fe24294..cb0de450a73ad7d141941536c003f4f057cfddf7 100644 (file)
@@ -163,6 +163,12 @@ HintsDialog::pulse ()
 void
 HintsDialog::finished ()
 {
 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 ();
        _finished = true;
        update ();
        _gauge->Hide ();