Fix exception on adding an empty folder as content (#691).
authorCarl Hetherington <cth@carlh.net>
Wed, 16 Sep 2015 22:43:15 +0000 (23:43 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 Sep 2015 22:43:15 +0000 (23:43 +0100)
ChangeLog
src/lib/content_factory.cc
src/wx/content_panel.cc

index 7fa5553f320d12c9d20e75a9d25bf1fb7f5343b3..ef152fe25cb1ea9e5b22d4540244c6d3718d8c46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-09-16  Carl Hetherington  <cth@carlh.net>
 
+       * Fix exception on adding an empty folder
+       as content (#691).
+
        * Add config option for default standard
        (SMPTE / Interop).
 
index c61889363fda9a62837c15acd51b4c85f0b20fc1..5b6d71641929023aa3fd06fe0f43f99e9ac29ae3 100644 (file)
@@ -77,6 +77,11 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
        shared_ptr<Content> content;
 
        if (boost::filesystem::is_directory (path)) {
+
+               if (boost::filesystem::is_empty (path)) {
+                       return shared_ptr<Content> ();
+               }
+
                /* Guess if this is a DCP or a set of images: read the first ten filenames and if they
                   are all valid image files we assume it is a set of images.
                */
index 2552f50987c8136c125239674807a5ff1c1150c9..8ca0d5b29854bc9ba58611fda2db3f61098027eb 100644 (file)
@@ -277,6 +277,10 @@ ContentPanel::add_folder_clicked ()
        }
 
        shared_ptr<Content> content = content_factory (_film, path);
+       if (!content) {
+               error_dialog (_parent, _("No content found in this folder."));
+               return;
+       }
 
        shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (content);
        if (ic) {