Third round of international character cleanup, see issue #413
This commit is contained in:
@@ -427,7 +427,7 @@
|
||||
+
|
||||
+ THREAD_LOCK
|
||||
+
|
||||
+ ifname = safe_locale_from_utf8(fname).c_str();
|
||||
+ ifname = fname.c_str();
|
||||
+ image = NULL;
|
||||
+ exif_base = -1;
|
||||
+ ciff_base = -1;
|
||||
@@ -641,7 +641,7 @@
|
||||
+ THREAD_LOCK
|
||||
+
|
||||
+ image = NULL;
|
||||
+ ifname = safe_locale_from_utf8(fname).c_str();
|
||||
+ ifname = fname.c_str();
|
||||
+ exif_base = -1;
|
||||
+ ciff_base = -1;
|
||||
+ ciff_len = -1;
|
||||
@@ -705,7 +705,7 @@
|
||||
+t0.set ();
|
||||
+
|
||||
+ image = NULL;
|
||||
+ ifname = safe_locale_from_utf8(fname).c_str();
|
||||
+ ifname = fname.c_str();
|
||||
+ exif_base = -1;
|
||||
+ ciff_base = -1;
|
||||
+ ciff_len = -1;
|
||||
|
@@ -128,7 +128,7 @@ skip_block: ;
|
||||
|
||||
int RawImage::loadRaw (bool loadData, bool closeFile)
|
||||
{
|
||||
ifname = safe_locale_from_utf8(filename).c_str();
|
||||
ifname = filename.c_str();
|
||||
image = NULL;
|
||||
verbose = settings->verbose;
|
||||
oprof = NULL;
|
||||
|
@@ -162,27 +162,6 @@ std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str)
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string safe_filename_from_utf8 (const Glib::ustring& utf8_str)
|
||||
{
|
||||
std::string str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
str = Glib::filename_from_utf8 (utf8_str);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
//str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
str = Glib::filename_from_utf8 (utf8_str, error);
|
||||
/*if (error.get())
|
||||
{str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?", error);}*/
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return str;
|
||||
}
|
||||
|
||||
bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
|
||||
{
|
||||
std::string cmd;
|
||||
@@ -191,7 +170,7 @@ bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
|
||||
try {
|
||||
cmd = Glib::filename_from_utf8(cmd_utf8);
|
||||
printf ("command line: |%s|\n", cmd.c_str());
|
||||
Glib::spawn_command_line_async (cmd);
|
||||
Glib::spawn_command_line_async (cmd.c_str());
|
||||
success = true;
|
||||
} catch (Glib::Exception& ex) {
|
||||
printf ("%s\n", ex.what().c_str());
|
||||
@@ -221,11 +200,11 @@ bool safe_spawn_command_line_sync (const Glib::ustring& cmd_utf8)
|
||||
|
||||
int exitStatus=-1;
|
||||
try {
|
||||
cmd = Glib::filename_from_utf8(cmd_utf8);
|
||||
printf ("command line: |%s|\n", cmd.c_str());
|
||||
//cmd = Glib::filename_from_utf8(cmd_utf8);
|
||||
printf ("command line: |%s|\n", cmd_utf8.c_str());
|
||||
|
||||
// if it crashes here on windows, make sure you have the GTK runtime files gspawn-win32-helper*.exe files in RT directory
|
||||
Glib::spawn_command_line_sync (cmd,NULL,NULL, &exitStatus);
|
||||
Glib::spawn_command_line_sync (cmd_utf8, NULL, NULL, &exitStatus);
|
||||
} catch (Glib::Exception& ex) {
|
||||
printf ("%s\n", ex.what().c_str());
|
||||
}
|
||||
@@ -234,25 +213,25 @@ bool safe_spawn_command_line_sync (const Glib::ustring& cmd_utf8)
|
||||
|
||||
FILE * safe_g_fopen(const Glib::ustring& src,const gchar *mode)
|
||||
{
|
||||
return g_fopen(safe_filename_from_utf8(src).c_str(),mode);
|
||||
return g_fopen(src.c_str(),mode);
|
||||
}
|
||||
|
||||
bool safe_file_test (const Glib::ustring& filename, Glib::FileTest test)
|
||||
{
|
||||
return Glib::file_test (safe_filename_from_utf8(filename), test);
|
||||
return Glib::file_test (filename, test);
|
||||
}
|
||||
|
||||
int safe_g_remove(const Glib::ustring& filename)
|
||||
{
|
||||
return ::g_remove(safe_filename_from_utf8(filename).c_str());
|
||||
return ::g_remove(filename.c_str());
|
||||
}
|
||||
|
||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename)
|
||||
{
|
||||
return ::g_rename(safe_filename_from_utf8(oldFilename).c_str(), safe_filename_from_utf8(newFilename).c_str());
|
||||
return ::g_rename(oldFilename.c_str(), newFilename.c_str());
|
||||
}
|
||||
|
||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode)
|
||||
{
|
||||
return ::g_mkdir_with_parents(safe_filename_from_utf8(dirName).c_str(), mode);
|
||||
return ::g_mkdir_with_parents(dirName.c_str(), mode);
|
||||
}
|
@@ -346,14 +346,17 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) {
|
||||
|
||||
const CacheImageData* cfs=openThm->getCacheImageData();
|
||||
if (!options.customProfileBuilder.empty() && !openThm->hasProcParams() && cfs && cfs->exifValid) {
|
||||
// For the filename etc. do NOT use streams, since they are not UTF8 safe
|
||||
Glib::ustring cmdLine=Glib::ustring("\"") + options.customProfileBuilder + Glib::ustring("\" \"") + openThm->getFileName() + Glib::ustring("\" \"")
|
||||
+ options.rtdir + Glib::ustring("/") + options.profilePath + Glib::ustring("/") + defProf + Glib::ustring(".pp3") + Glib::ustring("\" ");
|
||||
|
||||
// ustring doesn't know int etc formatting, so take these via (unsafe) stream
|
||||
std::ostringstream strm;
|
||||
strm << Glib::ustring("\"") << options.customProfileBuilder << Glib::ustring("\" \"") << openThm->getFileName() << Glib::ustring("\" \"");
|
||||
strm << options.rtdir << Glib::ustring("/") << options.profilePath << Glib::ustring("/") << defProf << Glib::ustring(".pp3");
|
||||
strm << Glib::ustring("\" ") << cfs->fnumber << Glib::ustring(" ") << cfs->shutter << Glib::ustring(" ");
|
||||
strm << cfs->fnumber << Glib::ustring(" ") << cfs->shutter << Glib::ustring(" ");
|
||||
strm << cfs->focalLen << Glib::ustring(" ") << cfs->iso << Glib::ustring(" \"");
|
||||
strm << cfs->lens << Glib::ustring("\" \"") << cfs->camera << Glib::ustring("\"");
|
||||
|
||||
bool success = safe_spawn_command_line_sync (strm.str());
|
||||
bool success = safe_spawn_command_line_sync (cmdLine + strm.str());
|
||||
|
||||
// Now they SHOULD be there, so try to load them
|
||||
if (success) openThm->loadProcParams();
|
||||
|
@@ -42,7 +42,9 @@ void SoundManager::playSoundAsync(const Glib::ustring &sound)
|
||||
sndParam|=SND_ALIAS;
|
||||
}
|
||||
|
||||
PlaySound(safe_filename_from_utf8(sound).c_str(), NULL, sndParam);
|
||||
wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (sound.c_str(), -1, NULL, NULL, NULL);
|
||||
PlaySoundW(wfilename, NULL, sndParam);
|
||||
g_free( wfilename );
|
||||
#else
|
||||
// TODO: Add code for other OSes here
|
||||
printf("Sound not supported on your OS (yet)\n");
|
||||
|
@@ -522,7 +522,9 @@ bool Thumbnail::openDefaultViewer(int destination) {
|
||||
if (destination==1) {
|
||||
openFName = Glib::ustring::compose ("%1.%2", BatchQueue::calcAutoFileNameBase(fname), options.saveFormat.format);
|
||||
if (safe_file_test (openFName, Glib::FILE_TEST_EXISTS)) {
|
||||
ShellExecute(NULL, "open", openFName.c_str(), NULL, NULL, SW_SHOWMAXIMIZED );
|
||||
wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (openFName.c_str(), -1, NULL, NULL, NULL);
|
||||
ShellExecuteW(NULL, L"open", wfilename, NULL, NULL, SW_SHOWMAXIMIZED );
|
||||
g_free(wfilename);
|
||||
} else {
|
||||
printf("File not found\n");
|
||||
return false;
|
||||
@@ -535,23 +537,26 @@ bool Thumbnail::openDefaultViewer(int destination) {
|
||||
|
||||
if (safe_file_test (openFName, Glib::FILE_TEST_EXISTS)) {
|
||||
// Output file exists, so open explorer and select output file
|
||||
const char* org=Glib::ustring::compose("/select,\"%1\"", openFName).c_str();
|
||||
char* par=new char[strlen(org)+1];
|
||||
strcpy(par, org);
|
||||
wchar_t* org=(wchar_t*)g_utf8_to_utf16 (Glib::ustring::compose("/select,\"%1\"", openFName).c_str(), -1, NULL, NULL, NULL);
|
||||
wchar_t* par=new wchar_t[wcslen(org)+1];
|
||||
wcscpy(par, org);
|
||||
|
||||
// In this case the / disturbs
|
||||
char* p = par+1; // skip the first backslash
|
||||
wchar_t* p = par+1; // skip the first backslash
|
||||
while (*p!=0) {
|
||||
if (*p=='/') *p='\\';
|
||||
if (*p==L'/') *p=L'\\';
|
||||
p++;
|
||||
}
|
||||
|
||||
ShellExecute(NULL, "open", "explorer.exe", par, NULL, SW_SHOWNORMAL );
|
||||
ShellExecuteW(NULL, L"open", L"explorer.exe", par, NULL, SW_SHOWNORMAL );
|
||||
|
||||
delete[] par;
|
||||
g_free(org);
|
||||
} else if (safe_file_test (Glib::path_get_dirname(openFName), Glib::FILE_TEST_EXISTS)) {
|
||||
// Out file does not exist, but directory
|
||||
ShellExecute(NULL, "explore", Glib::path_get_dirname(openFName).c_str(), NULL, NULL, SW_SHOWNORMAL );
|
||||
wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (Glib::path_get_dirname(openFName).c_str(), -1, NULL, NULL, NULL);
|
||||
ShellExecuteW(NULL, L"explore", wfilename, NULL, NULL, SW_SHOWNORMAL );
|
||||
g_free(wfilename);
|
||||
} else {
|
||||
printf("File and dir not found\n");
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user