Workaround for issue 1794: "Cannot save image or PP3 from Image Editor" ; properly catching exceptions on Windows should be preferred ; this patch is a clean fix for Linux and MacOS

This commit is contained in:
natureh 510
2013-04-10 01:12:42 +02:00
parent d8a9e4fc5b
commit de5026188d
4 changed files with 61 additions and 5 deletions

View File

@@ -406,3 +406,16 @@ Glib::ustring safe_get_user_picture_dir() {
#endif
}
#ifdef WIN32
/*
* Test if the path is a root path based on the content of the string
*
* Warning: this function is a workaround for Windows platform, and not necessarily bullet proof
*/
bool safe_is_root_dir (const Glib::ustring& path) {
Glib::ustring t = Glib::path_skip_root(path);
return t.empty();
}
#endif

View File

@@ -41,4 +41,9 @@ int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFile
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
Glib::ustring safe_get_user_picture_dir();
#ifdef WIN32
bool safe_is_root_dir (const Glib::ustring& filename);
#endif
#endif

View File

@@ -138,9 +138,23 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
dialog.set_current_name (lastFilename);
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
#ifdef WIN32
// Dirty workaround, waiting for a clean solution by using exceptions!
if (!safe_is_root_dir(options.getPreferredProfilePath()))
#endif
try {
dialog.add_shortcut_folder(options.getPreferredProfilePath());
}
catch (Gtk::FileChooserError &err) {}
//Add the image's path to the Shortcut list
#ifdef WIN32
// Dirty workaround, waiting for a clean solution by using exceptions!
if (!safe_is_root_dir(imagePath))
#endif
try {
dialog.add_shortcut_folder(imagePath);
}
catch (Gtk::FileChooserError &err) {}
//Add response buttons the the dialog:
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
@@ -272,9 +286,24 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
FileChooserLastFolderPersister persister( &dialog, options.loadSaveProfilePath );
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
#ifdef WIN32
// Dirty workaround, waiting for a clean solution by using exceptions!
if (!safe_is_root_dir(options.getPreferredProfilePath()))
#endif
try {
dialog.add_shortcut_folder(options.getPreferredProfilePath());
}
catch (Gtk::FileChooserError &err) {}
//Add the image's path to the Shortcut list
#ifdef WIN32
// Dirty workaround, waiting for a clean solution by using exceptions!
if (!safe_is_root_dir(imagePath))
#endif
try {
dialog.add_shortcut_folder(imagePath);
}
catch (Gtk::FileChooserError &err) {}
//Add response buttons the the dialog:
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);

View File

@@ -255,6 +255,15 @@ void SaveAsDialog::setInitialFileName (Glib::ustring fname) {
void SaveAsDialog::setImagePath (Glib::ustring ipath) {
Glib::ustring path = Glib::path_get_dirname(ipath);
//Add the image's path to the Shortcut list
fchooser->add_shortcut_folder(Glib::path_get_dirname(ipath));
#ifdef WIN32
// Dirty workaround, waiting for a clean solution by using exceptions!
if (!safe_is_root_dir(path))
#endif
try {
fchooser->add_shortcut_folder(Glib::path_get_dirname(path));
}
catch (Gtk::FileChooserError &err) {}
}