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:
@@ -406,3 +406,16 @@ Glib::ustring safe_get_user_picture_dir() {
|
|||||||
|
|
||||||
#endif
|
#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
|
||||||
|
|
||||||
|
@@ -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);
|
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
|
||||||
|
|
||||||
Glib::ustring safe_get_user_picture_dir();
|
Glib::ustring safe_get_user_picture_dir();
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
bool safe_is_root_dir (const Glib::ustring& filename);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -138,9 +138,23 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
|
|||||||
dialog.set_current_name (lastFilename);
|
dialog.set_current_name (lastFilename);
|
||||||
|
|
||||||
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
#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
|
//Add the image's path to the Shortcut list
|
||||||
dialog.add_shortcut_folder(imagePath);
|
#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:
|
//Add response buttons the the dialog:
|
||||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
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 );
|
FileChooserLastFolderPersister persister( &dialog, options.loadSaveProfilePath );
|
||||||
|
|
||||||
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
#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
|
//Add the image's path to the Shortcut list
|
||||||
dialog.add_shortcut_folder(imagePath);
|
#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:
|
//Add response buttons the the dialog:
|
||||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||||
|
@@ -255,6 +255,15 @@ void SaveAsDialog::setInitialFileName (Glib::ustring fname) {
|
|||||||
|
|
||||||
void SaveAsDialog::setImagePath (Glib::ustring ipath) {
|
void SaveAsDialog::setImagePath (Glib::ustring ipath) {
|
||||||
|
|
||||||
|
Glib::ustring path = Glib::path_get_dirname(ipath);
|
||||||
|
|
||||||
//Add the image's path to the Shortcut list
|
//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) {}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user