summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-20 17:01:52 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-20 17:01:52 +0100
commit0082d0c784a83746d883182ce49ea298f7a1390e (patch)
treef1d7caef4cd9a80fa493ad6e3e14f8b177031c61 /src
parenta7dc6ea9175883f439786bd6d15156a24390e109 (diff)
Don't crash with bad content (#135).
Diffstat (limited to 'src')
-rw-r--r--src/lib/film.cc9
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/job.cc11
3 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 031b4f1f4..e39e94cfc 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -744,13 +744,18 @@ void
Film::examine_and_add_content (shared_ptr<Content> c)
{
shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
- j->Finished.connect (bind (&Film::add_content_weak, this, boost::weak_ptr<Content> (c)));
+ j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)));
JobManager::instance()->add (j);
}
void
-Film::add_content_weak (weak_ptr<Content> c)
+Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c)
{
+ shared_ptr<Job> job = j.lock ();
+ if (!job || !job->finished_ok ()) {
+ return;
+ }
+
shared_ptr<Content> content = c.lock ();
if (content) {
add_content (content);
diff --git a/src/lib/film.h b/src/lib/film.h
index 834de6cbe..99c214ab7 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -239,7 +239,7 @@ private:
void playlist_changed ();
void playlist_content_changed (boost::weak_ptr<Content>, int);
std::string filename_safe_name () const;
- void add_content_weak (boost::weak_ptr<Content>);
+ void maybe_add_content (boost::weak_ptr<Job>, boost::weak_ptr<Content>);
/** Log to write to */
boost::shared_ptr<Log> _log;
diff --git a/src/lib/job.cc b/src/lib/job.cc
index 4fbe70771..5d8a68ec0 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -28,6 +28,7 @@
#include "util.h"
#include "cross.h"
#include "ui_signaller.h"
+#include "exceptions.h"
#include "i18n.h"
@@ -83,6 +84,16 @@ Job::run_wrapper ()
set_error (e.what(), m);
+ } catch (OpenFileError& e) {
+
+ set_progress (1);
+ set_state (FINISHED_ERROR);
+
+ set_error (
+ String::compose (_("Could not open %1"), e.file().string()),
+ String::compose (_("DCP-o-matic could not open the file %1. Perhaps it does not exist or is in an unexpected format."), e.file().string())
+ );
+
} catch (boost::thread_interrupted &) {
set_state (FINISHED_CANCELLED);