Make load_user_special_dirs() resistant to nonexistent dirs

This commit is contained in:
Matthias Clasen 2011-01-27 21:57:57 -05:00
parent 4f8a4f171e
commit cc5578fbd7

View File

@ -2427,10 +2427,15 @@ load_user_special_dirs (void)
{ {
wcp = NULL; wcp = NULL;
(*p_SHGetKnownFolderPath) (&FOLDERID_Downloads, 0, NULL, &wcp); (*p_SHGetKnownFolderPath) (&FOLDERID_Downloads, 0, NULL, &wcp);
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL); if (wcp)
if (g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] == NULL) {
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY); g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
CoTaskMemFree (wcp); if (g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] == NULL)
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
CoTaskMemFree (wcp);
}
else
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
} }
g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = get_special_folder (CSIDL_MYMUSIC); g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = get_special_folder (CSIDL_MYMUSIC);
@ -2445,10 +2450,15 @@ load_user_special_dirs (void)
{ {
wcp = NULL; wcp = NULL;
(*p_SHGetKnownFolderPath) (&FOLDERID_Public, 0, NULL, &wcp); (*p_SHGetKnownFolderPath) (&FOLDERID_Public, 0, NULL, &wcp);
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL); if (wcp)
if (g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] == NULL) {
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS); g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
CoTaskMemFree (wcp); if (g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] == NULL)
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
CoTaskMemFree (wcp);
}
else
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
} }
g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = get_special_folder (CSIDL_TEMPLATES); g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = get_special_folder (CSIDL_TEMPLATES);