Open an error dialogue on uncaught exceptions in the main loop. Check that the Image...
authorCarl Hetherington <cth@carlh.net>
Sun, 27 Apr 2014 19:50:13 +0000 (20:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 27 Apr 2014 19:50:13 +0000 (20:50 +0100)
ChangeLog
src/lib/image_content.cc
src/lib/job.cc
src/tools/dcpomatic.cc
src/wx/film_editor.cc

index 0393afe76d5197a6b956cae1ed77572ab6289e7e..4911adf1bd9a534212711ba1b0f565c19df5d348 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2014-04-27  Carl Hetherington  <cth@carlh.net>
 
+       * Slightly better handling of uncaught exceptions.
+
        * Use our own directory picker on 14.04 (as well as 13.04 and 13.10) as
        it appears that the same bug remains.
 
index 13f7c52e3d12dec4256479d0d0bdbcec7c795253..3b87fcf008c4372114e77009e424dbdd30dd5cf6 100644 (file)
@@ -44,7 +44,11 @@ ImageContent::ImageContent (shared_ptr<const Film> f, boost::filesystem::path p)
                                _paths.push_back (i->path ());
                        }
                }
-               
+
+               if (_paths.empty()) {
+                       throw FileError (_("No valid image files were found in the folder."), p);
+               }
+                               
                sort (_paths.begin(), _paths.end());
        }
 }
index 52499b43329348c0a97739e6d81cdf6c974783bf..96aedac65bf4fb8718d8749712db3ae28d9ae627 100644 (file)
@@ -108,7 +108,7 @@ Job::run_wrapper ()
 
                set_error (
                        e.what (),
-                       _("It is not known what caused this error.  The best idea is to report the problem to the DCP-o-matic mailing list (carl@dcpomatic.com)")
+                       _("It is not known what caused this error.  Please report the problem to the DCP-o-matic author (carl@dcpomatic.com).")
                        );
 
                set_progress (1);
@@ -118,7 +118,7 @@ Job::run_wrapper ()
 
                set_error (
                        _("Unknown error"),
-                       _("It is not known what caused this error.  The best idea is to report the problem to the DCP-o-matic mailing list (carl@dcpomatic.com)")
+                       _("It is not known what caused this error.  Please report the problem to the DCP-o-matic author (carl@dcpomatic.com).")
                        );
 
                set_progress (1);
index 2f64371aebcc11c50e7561222292d879f815f15d..1abd2519853b120f15369c20540fd0e39c6cdcc3 100644 (file)
@@ -733,6 +733,17 @@ class App : public wxApp
                return true;
        }
 
+       bool OnExceptionInMainLoop ()
+       {
+               error_dialog (0, _("An unknown exception occurred.  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
+               return false;
+       }
+               
+       void OnUnhandledException ()
+       {
+               error_dialog (0, _("An unknown exception occurred.  Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
+       }
+
        void idle ()
        {
                ui_signaller->ui_idle ();
index 31b9b8368b0097e006c974c20aef437fa4db1111..1131675bc10319216f07ca5a7ed8d549eb84d15b 100644 (file)
@@ -803,11 +803,16 @@ FilmEditor::content_add_folder_clicked ()
                return;
        }
 
-       _film->examine_and_add_content (
-               shared_ptr<ImageContent> (
-                       new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
-                       )
-               );
+       shared_ptr<ImageContent> ic;
+       
+       try {
+               ic.reset (new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+       } catch (FileError& e) {
+               error_dialog (this, std_to_wx (e.what ()));
+               return;
+       }
+
+       _film->examine_and_add_content (ic);
 }
 
 void