diff options
author | McCabe Maxsted | 2009-03-01 04:13:19 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-03-01 04:13:19 -0700 |
commit | 8036835628d66b3561668eb4872debed3075ca5d (patch) | |
tree | d54e1a6019242e72405622cdbc4b74516d73034b /linden/indra/newview/llfilepicker.cpp | |
parent | Fixed pause button texture showing up in certain instances (diff) | |
download | meta-impy-8036835628d66b3561668eb4872debed3075ca5d.zip meta-impy-8036835628d66b3561668eb4872debed3075ca5d.tar.gz meta-impy-8036835628d66b3561668eb4872debed3075ca5d.tar.bz2 meta-impy-8036835628d66b3561668eb4872debed3075ca5d.tar.xz |
Fixed crash involving file picker and locales (patch by Alissa Sabre)
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfilepicker.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp index bbcfba6..1edfbe6 100644 --- a/linden/indra/newview/llfilepicker.cpp +++ b/linden/indra/newview/llfilepicker.cpp | |||
@@ -899,12 +899,41 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) | |||
899 | // static | 899 | // static |
900 | void LLFilePicker::add_to_selectedfiles(gpointer data, gpointer user_data) | 900 | void LLFilePicker::add_to_selectedfiles(gpointer data, gpointer user_data) |
901 | { | 901 | { |
902 | LLFilePicker* picker = (LLFilePicker*) user_data; | 902 | // We need to run g_filename_to_utf8 in the user's locale |
903 | std::string old_locale(setlocale(LC_ALL, NULL)); | ||
904 | setlocale(LC_ALL, ""); | ||
905 | |||
906 | LLFilePicker* picker = (LLFilePicker*) user_data; | ||
907 | GError *error = NULL; | ||
903 | gchar* filename_utf8 = g_filename_to_utf8((gchar*)data, | 908 | gchar* filename_utf8 = g_filename_to_utf8((gchar*)data, |
904 | -1, NULL, NULL, NULL); | 909 | -1, NULL, NULL, &error); |
905 | picker->mFiles.push_back(std::string(filename_utf8)); | 910 | if (error) |
906 | lldebugs << "ADDED FILE " << filename_utf8 << llendl; | 911 | { |
907 | g_free(filename_utf8); | 912 | // This condition should really be notified to the user, e.g., |
913 | // through a message box. Just logging it is inapropriate. | ||
914 | // FIXME. | ||
915 | |||
916 | // Ghhhh. g_filename_display_name is new to glib 2.6, and it | ||
917 | // is too new for SL! (Note that the latest glib as of this | ||
918 | // writing is 2.22. *sigh*) LL supplied *makeASCII family are | ||
919 | // also unsuitable since they allow control characters... | ||
920 | |||
921 | std::string display_name; | ||
922 | for (const gchar *str = (const gchar *)data; *str; str++) | ||
923 | { | ||
924 | display_name += (char)((*str >= 0x20 && *str <= 0x7E) ? *str : '?'); | ||
925 | } | ||
926 | llwarns << "g_filename_to_utf8 failed on \"" << display_name << "\": " << error->message << llendl; | ||
927 | } | ||
928 | |||
929 | if (filename_utf8) | ||
930 | { | ||
931 | picker->mFiles.push_back(std::string(filename_utf8)); | ||
932 | lldebugs << "ADDED FILE " << filename_utf8 << llendl; | ||
933 | g_free(filename_utf8); | ||
934 | } | ||
935 | |||
936 | setlocale(LC_ALL, old_locale.c_str()); | ||
908 | } | 937 | } |
909 | 938 | ||
910 | // static | 939 | // static |