浏览代码

Bug 1547: Do not display error message on start when user documents folder cannot be resolved

https://winscp.net/tracker/1547

Source commit: 6c711e251ad11dcf3bd0afd71f9f3a53bc5617ee
Martin Prikryl 8 年之前
父节点
当前提交
df34a0bf87
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 8 1
      source/packages/filemng/BaseUtils.pas
  2. 2 1
      source/packages/filemng/DirView.pas

+ 8 - 1
source/packages/filemng/BaseUtils.pas

@@ -339,7 +339,14 @@ begin
   Result :=
     (not Failed(SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL))) and
     SHGetPathFromIDList(PIDL, PChar(Path));
-  if Result then SetLength(Path, StrLen(PChar(Path)));
+  if Result then
+  begin
+    SetLength(Path, StrLen(PChar(Path)));
+  end
+    else
+  begin
+    Path := '';
+  end;
 end;
 
 function SpecialFolderLocation(Folder: Integer; var Path: string): Boolean;

+ 2 - 1
source/packages/filemng/DirView.pas

@@ -750,7 +750,8 @@ begin
     else
   begin
     Result := UserDocumentDirectory;
-    if IsUNCPath(Result) then
+    if (Result = '') or // in rare case the CSIDL_PERSONAL cannot be resolved
+       IsUNCPath(Result) then
     begin
       Result := AnyValidPath;
     end;