fix error displayed after refreshing list of git branches

and when opening a project that's not a repo
This commit is contained in:
Basile Burg 2018-08-01 02:14:13 +02:00
parent 9c3460a501
commit c8c69e3f40
1 changed files with 18 additions and 6 deletions

View File

@ -4054,7 +4054,6 @@ begin
end; end;
end; end;
procedure TCEMainForm.gitBranchMenuItemClick(sender: TObject); procedure TCEMainForm.gitBranchMenuItemClick(sender: TObject);
var var
p: TProcess; p: TProcess;
@ -4062,6 +4061,8 @@ var
i: integer; i: integer;
b: string; b: string;
begin begin
if not assigned(fProject) then
exit;
p := TProcess.Create(nil); p := TProcess.Create(nil);
r := TStringList.Create; r := TStringList.Create;
b := TMenuItem(sender).Caption; b := TMenuItem(sender).Caption;
@ -4093,8 +4094,16 @@ var
r: TStringList; r: TStringList;
i: integer; i: integer;
m: TMenuItem; m: TMenuItem;
a: boolean;
begin begin
mnuGitBranch.Clear; if not assigned(fProject) then
exit;
a := mnuGitBranch.Count >= 2;
if a then
while mnuGitBranch.Count <> 2 do
mnuGitBranch.delete(mnuGitBranch.Count-1);
if not DirectoryExistsUTF8(fProject.basePath + DirectorySeparator + '.git') then
exit;
p := TProcess.Create(nil); p := TProcess.Create(nil);
r := TStringList.Create; r := TStringList.Create;
try try
@ -4109,10 +4118,13 @@ begin
p.Execute; p.Execute;
processOutputToStrings(p,r); processOutputToStrings(p,r);
while p.Running do ; while p.Running do ;
m := TMenuItem.Create(mnuGitBranch); if not a then
m.action := actProjGitBranchesUpd; begin
mnuGitBranch.Add(m); m := TMenuItem.Create(mnuGitBranch);
mnuGitBranch.AddSeparator; m.action := actProjGitBranchesUpd;
mnuGitBranch.Add(m);
mnuGitBranch.AddSeparator;
end;
for i:= 0 to r.Count-1 do for i:= 0 to r.Count-1 do
begin begin
m := TMenuItem.Create(mnuGitBranch); m := TMenuItem.Create(mnuGitBranch);