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 cf14f06..a9b9d6f 100644 (file)
@@ -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)));
index 00c2486..e9a75fb 100644 (file)
@@ -30,7 +30,7 @@
 
 class Film;
 
-class Hints : public Signaller
+class Hints : public Signaller, public ExceptionStore
 {
 public:
        explicit Hints (boost::weak_ptr<const Film> film);
index f8d0362..cb0de45 100644 (file)
@@ -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 ();