From c8c69e3f4077eb54248ed71172c42b11c893382f Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 1 Aug 2018 02:14:13 +0200 Subject: [PATCH] fix error displayed after refreshing list of git branches and when opening a project that's not a repo --- src/ce_main.pas | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ce_main.pas b/src/ce_main.pas index 4a2ed37a..62546aad 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -4054,7 +4054,6 @@ begin end; end; - procedure TCEMainForm.gitBranchMenuItemClick(sender: TObject); var p: TProcess; @@ -4062,6 +4061,8 @@ var i: integer; b: string; begin + if not assigned(fProject) then + exit; p := TProcess.Create(nil); r := TStringList.Create; b := TMenuItem(sender).Caption; @@ -4093,8 +4094,16 @@ var r: TStringList; i: integer; m: TMenuItem; + a: boolean; 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); r := TStringList.Create; try @@ -4109,10 +4118,13 @@ begin p.Execute; processOutputToStrings(p,r); while p.Running do ; - m := TMenuItem.Create(mnuGitBranch); - m.action := actProjGitBranchesUpd; - mnuGitBranch.Add(m); - mnuGitBranch.AddSeparator; + if not a then + begin + m := TMenuItem.Create(mnuGitBranch); + m.action := actProjGitBranchesUpd; + mnuGitBranch.Add(m); + mnuGitBranch.AddSeparator; + end; for i:= 0 to r.Count-1 do begin m := TMenuItem.Create(mnuGitBranch);