swaroop: at least partially fix crashes when trying to set the background image to... v2.13.87
authorCarl Hetherington <cth@carlh.net>
Tue, 18 Dec 2018 22:50:30 +0000 (22:50 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Dec 2018 22:50:30 +0000 (22:50 +0000)
src/wx/player_config_dialog.cc

index b16c76b363f27648159640991c36eb87b72f3458..ab72284382bb4d0dac01099121a33bc62f7fc464 100644 (file)
@@ -313,7 +313,16 @@ private:
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        void background_image_changed ()
        {
-               Config::instance()->set_player_background_image(wx_to_std(_background_image->GetPath()));
+               boost::filesystem::path const f = wx_to_std(_background_image->GetPath());
+               if (!boost::filesystem::is_regular_file(f) || !wxImage::CanRead(std_to_wx(f.string()))) {
+                       error_dialog (0, _("Could not load image file."));
+                       if (Config::instance()->player_background_image()) {
+                               checked_set (_background_image, *Config::instance()->player_background_image());
+                       }
+                       return;
+               }
+
+               Config::instance()->set_player_background_image(f);
        }
 #endif