Don't crash if preferences ZIP needs to be overwritten during export.
authorCarl Hetherington <cth@carlh.net>
Sun, 26 Nov 2023 20:05:20 +0000 (21:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 26 Nov 2023 20:05:20 +0000 (21:05 +0100)
src/tools/dcpomatic.cc

index 979672fb4274e4ce110b08aad0189e993f168549..11181ae588067f89539af0d72df2d255759dc6fd 100644 (file)
@@ -762,7 +762,17 @@ private:
                        );
 
                if (dialog.ShowModal() == wxID_OK) {
-                       save_all_config_as_zip(wx_to_std(dialog.GetPath()));
+                       auto const path = boost::filesystem::path(wx_to_std(dialog.GetPath()));
+                       if (boost::filesystem::exists(path)) {
+                               boost::system::error_code ec;
+                               boost::filesystem::remove(path, ec);
+                               if (ec) {
+                                       error_dialog(nullptr, _("Could not remove existing preferences file"), std_to_wx(path.string()));
+                                       return;
+                               }
+                       }
+
+                       save_all_config_as_zip(path);
                }
        }