From af3e8ed8382cdc35e361cdca1f735a379fce1317 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 28 Dec 2013 15:00:38 +0000 Subject: [PATCH] Remove unused Film::content_paths_valid; fix ImageDecoder to throw an OpenFileError when a file is missing so that it gets treated as missing content; rename Content::path_valid -> paths_valid. --- ChangeLog | 4 ++++ src/lib/content.cc | 2 +- src/lib/content.h | 2 +- src/lib/film.cc | 6 ------ src/lib/film.h | 1 - src/lib/image_decoder.cc | 9 ++++++++- src/lib/playlist.cc | 12 ------------ src/lib/playlist.h | 2 -- src/wx/content_menu.cc | 2 +- src/wx/film_editor.cc | 2 +- 10 files changed, 16 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7feabc198..c80ad2e63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-28 Carl Hetherington + + * Fix failure to load films with missing still image content (#300). + 2013-12-27 Carl Hetherington * Fix non-update of video information on changing DCP resolution (#299). diff --git a/src/lib/content.cc b/src/lib/content.cc index f09012765..d835a5b05 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -232,7 +232,7 @@ Content::identifier () const } bool -Content::path_valid () const +Content::paths_valid () const { for (vector::const_iterator i = _paths.begin(); i != _paths.end(); ++i) { if (!boost::filesystem::exists (*i)) { diff --git a/src/lib/content.h b/src/lib/content.h index 9cf6d866a..4ee7c267f 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -84,7 +84,7 @@ public: return _paths[i]; } - bool path_valid () const; + bool paths_valid () const; /** @return MD5 digest of the content's file(s) */ std::string digest () const { diff --git a/src/lib/film.cc b/src/lib/film.cc index 5946d5bec..1bf35cc5f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -860,12 +860,6 @@ Film::best_video_frame_rate () const return _playlist->best_dcp_frame_rate (); } -bool -Film::content_paths_valid () const -{ - return _playlist->content_paths_valid (); -} - void Film::playlist_content_changed (boost::weak_ptr c, int p) { diff --git a/src/lib/film.h b/src/lib/film.h index 4b07f84a9..e318f7724 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -114,7 +114,6 @@ public: Time length () const; bool has_subtitles () const; OutputVideoFrame best_video_frame_rate () const; - bool content_paths_valid () const; libdcp::KDM make_kdm ( diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index fb6053ae5..a7999c02a 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -52,7 +52,14 @@ ImageDecoder::pass () return; } - Magick::Image* magick_image = new Magick::Image (_image_content->path (_image_content->still() ? 0 : _video_position).string ()); + Magick::Image* magick_image = 0; + boost::filesystem::path const path = _image_content->path (_image_content->still() ? 0 : _video_position); + try { + magick_image = new Magick::Image (path.string ()); + } catch (...) { + throw OpenFileError (path); + } + libdcp::Size size (magick_image->columns(), magick_image->rows()); _image.reset (new Image (PIX_FMT_RGB24, size, true)); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 37b290218..daa82cb94 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -389,15 +389,3 @@ Playlist::move_later (shared_ptr c) Changed (); } - -bool -Playlist::content_paths_valid () const -{ - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - if (!(*i)->path_valid ()) { - return false; - } - } - - return true; -} diff --git a/src/lib/playlist.h b/src/lib/playlist.h index f87b3397b..1915e3d04 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -80,8 +80,6 @@ public: void repeat (ContentList, int); - bool content_paths_valid () const; - mutable boost::signals2::signal Changed; /** Third parameter is true if signals are currently being emitted frequently */ mutable boost::signals2::signal, int, bool)> ContentChanged; diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 254109eb3..6372503d1 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -80,7 +80,7 @@ ContentMenu::popup (ContentList c, wxPoint p) _join->Enable (n > 1); - _find_missing->Enable (_content.size() == 1 && !_content.front()->path_valid ()); + _find_missing->Enable (_content.size() == 1 && !_content.front()->paths_valid ()); _remove->Enable (!_content.empty ()); _parent->PopupMenu (_menu, p); } diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index e478734c7..04bf6d2a8 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -734,7 +734,7 @@ FilmEditor::setup_content () ContentList content = _film->content (); for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { int const t = _content->GetItemCount (); - bool const valid = (*i)->path_valid (); + bool const valid = (*i)->paths_valid (); string s = (*i)->summary (); if (!valid) { -- 2.30.2