Solving issue 1794: "Cannot save image or PP3 from Image Editor"
This commit is contained in:
@@ -395,7 +395,7 @@ Glib::ustring safe_get_user_picture_dir() {
|
||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
||||
// so we use the safe native functions here
|
||||
WCHAR pathW[MAX_PATH]={0};
|
||||
if (SHGetSpecialFolderPathW(NULL,pathW,CSIDL_MYPICTURES,false)) {
|
||||
if (SHGetSpecialFolderPathW(NULL,pathW,CSIDL_MYPICTURES,false)) {
|
||||
char pathA[MAX_PATH];
|
||||
WideCharToMultiByte(CP_UTF8,0,pathW,-1,pathA,MAX_PATH,0,0);
|
||||
return Glib::ustring(pathA);
|
||||
@@ -408,14 +408,49 @@ Glib::ustring safe_get_user_picture_dir() {
|
||||
#endif
|
||||
}
|
||||
|
||||
Glib::ustring safe_get_user_home_dir() {
|
||||
#ifdef WIN32
|
||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
||||
// so we use the safe native functions here
|
||||
WCHAR pathW[MAX_PATH]={0};
|
||||
if (SHGetSpecialFolderPathW(NULL,pathW,CSIDL_PERSONAL,false)) {
|
||||
char pathA[MAX_PATH];
|
||||
WideCharToMultiByte(CP_UTF8,0,pathW,-1,pathA,MAX_PATH,0,0);
|
||||
return Glib::ustring(pathA);
|
||||
} else return Glib::ustring("C:\\");
|
||||
|
||||
#else
|
||||
|
||||
return Glib::get_home_dir();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
Glib::ustring safe_get_user_desktop_dir() {
|
||||
#ifdef WIN32
|
||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
||||
// so we use the safe native functions here
|
||||
WCHAR pathW[MAX_PATH]={0};
|
||||
if (SHGetSpecialFolderPathW(NULL,pathW,CSIDL_DESKTOP,false)) {
|
||||
char pathA[MAX_PATH];
|
||||
WideCharToMultiByte(CP_UTF8,0,pathW,-1,pathA,MAX_PATH,0,0);
|
||||
return Glib::ustring(pathA);
|
||||
} else return Glib::ustring("C:\\");
|
||||
|
||||
#else
|
||||
|
||||
return Glib::get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
||||
|
||||
#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) {
|
||||
return PathIsRootA(path.c_str());
|
||||
bool safe_is_shortcut_dir (const Glib::ustring& path) {
|
||||
return PathIsRootA(path.c_str()) || safe_get_user_home_dir() == path || safe_get_user_desktop_dir() == path; // || safe_get_user_picture_dir() == path;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -41,9 +41,11 @@ 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();
|
||||
Glib::ustring safe_get_user_home_dir();
|
||||
Glib::ustring safe_get_user_desktop_dir();
|
||||
|
||||
#ifdef WIN32
|
||||
bool safe_is_root_dir (const Glib::ustring& filename);
|
||||
bool safe_is_shortcut_dir (const Glib::ustring& filename);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -140,7 +140,7 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
|
||||
//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()))
|
||||
if (!safe_is_shortcut_dir(options.getPreferredProfilePath()))
|
||||
#endif
|
||||
try {
|
||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
||||
@@ -149,7 +149,7 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
|
||||
//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))
|
||||
if (!safe_is_shortcut_dir(imagePath))
|
||||
#endif
|
||||
try {
|
||||
dialog.add_shortcut_folder(imagePath);
|
||||
@@ -288,7 +288,7 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
|
||||
//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()))
|
||||
if (!safe_is_shortcut_dir(options.getPreferredProfilePath()))
|
||||
#endif
|
||||
try {
|
||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
||||
@@ -298,7 +298,7 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
|
||||
//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))
|
||||
if (!safe_is_shortcut_dir(imagePath))
|
||||
#endif
|
||||
try {
|
||||
dialog.add_shortcut_folder(imagePath);
|
||||
|
@@ -262,7 +262,7 @@ void SaveAsDialog::setImagePath (Glib::ustring ipath) {
|
||||
//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(path))
|
||||
if (!safe_is_shortcut_dir(path))
|
||||
#endif
|
||||
try {
|
||||
fchooser->add_shortcut_folder(path);
|
||||
|
Reference in New Issue
Block a user