Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2022-03-11 20:25:45 +0300
committerHarley Acheson <harley.acheson@gmail.com>2022-03-11 20:26:59 +0300
commitae3c8bc9f098b1be19da19f9d555bc7b22c2d03c (patch)
tree573ac31f24cbce567ec9db22065585bf93730fdc /source/blender/editors/space_file
parent5c86f0369c6fc458c828cf60268774ac0c4cf32a (diff)
Fix T85689: Replace SHGetFileInfoW for Drive Name
Win32: Replace SHGetFileInfoW as means to get friendly display names for volumes because it causes long pauses for disconnected remote drives. See D14305 for more details. Differential Revision: https://developer.blender.org/D14305 Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/fsmenu.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 988ba7728f1..847bf89bba8 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -29,6 +29,7 @@
* because 'near' is disabled through BLI_windstuff. */
# include "BLI_winstuff.h"
# include <shlobj.h>
+# include <shlwapi.h>
#endif
#include "UI_interface_icons.h"
@@ -642,14 +643,29 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
tmps[3] = '\0';
name = NULL;
- /* Flee from horrible win querying hover floppy drives! */
+ /* Skip over floppy disks A & B. */
if (i > 1) {
- /* Try to get a friendly drive description. */
- SHFILEINFOW shFile = {0};
+ /* Friendly volume descriptions without using SHGetFileInfoW (T85689). */
BLI_strncpy_wchar_from_utf8(wline, tmps, 4);
- if (SHGetFileInfoW(wline, 0, &shFile, sizeof(SHFILEINFOW), SHGFI_DISPLAYNAME)) {
- BLI_strncpy_wchar_as_utf8(line, shFile.szDisplayName, FILE_MAXDIR);
- name = line;
+ IShellFolder *desktop;
+ if (SHGetDesktopFolder(&desktop) == S_OK) {
+ PIDLIST_RELATIVE volume;
+ if (desktop->lpVtbl->ParseDisplayName(
+ desktop, NULL, NULL, wline, NULL, &volume, NULL) == S_OK) {
+ STRRET volume_name;
+ volume_name.uType = STRRET_WSTR;
+ if (desktop->lpVtbl->GetDisplayNameOf(
+ desktop, volume, SHGDN_FORADDRESSBAR, &volume_name) == S_OK) {
+ wchar_t *volume_name_wchar;
+ if (StrRetToStrW(&volume_name, volume, &volume_name_wchar) == S_OK) {
+ BLI_strncpy_wchar_as_utf8(line, volume_name_wchar, FILE_MAXDIR);
+ name = line;
+ CoTaskMemFree(volume_name_wchar);
+ }
+ }
+ CoTaskMemFree(volume);
+ }
+ desktop->lpVtbl->Release(desktop);
}
}
if (name == NULL) {