From 7151d1ab931680289765fb9f019116ad9ebe6fe9 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 13 Feb 2019 20:57:19 +0100 Subject: [PATCH] fix #448 - conversion to json fails depending on dub cwd --- src/u_dubproject.pas | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index eb38c6ac..0222d425 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -1746,15 +1746,25 @@ var jsn: TJSONData = nil; prs: TJSONParser; t: string; + d: string; begin result := nil; dub := TProcess.Create(nil); str := TStringList.Create; + + // see note about chdir + d := GetCurrentDir; + try dub.Executable := 'dub' + exeExt; dub.Options := [poUsePipes{$IFDEF WINDOWS}, poNewConsole{$ENDIF}]; dub.ShowWindow := swoHIDE; dub.CurrentDirectory:= filename.extractFilePath; + + // need to move because it looks like DUB doesn't use + // the cd specified for the process we launch here. + chdir(dub.CurrentDirectory); + dub.Parameters.Add('convert'); dub.Parameters.Add('-s'); dub.Parameters.Add('-f'); @@ -1786,6 +1796,10 @@ begin result := nil; end; finally + + // see note about chdir + chdir(d); + dub.free; str.Free; end;