From bf510fbd62d3d3df146c684d9465e5d9c85ed64c Mon Sep 17 00:00:00 2001 From: Margers Date: Sun, 16 Mar 2025 17:21:47 +0000 Subject: [PATCH] Revert: Refactor menu change code. --- packages/ide/fpide.pas | 25 ------------------------- packages/ide/fpmrun.inc | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/packages/ide/fpide.pas b/packages/ide/fpide.pas index 98847650ef..bb71e99396 100644 --- a/packages/ide/fpide.pas +++ b/packages/ide/fpide.pas @@ -850,31 +850,6 @@ begin IDEUseTabsPattern:={(Editor^.FileName='') or }MatchesMaskList(NameAndExtOf(Editor^.FileName),TabsPattern); end; -{replace menu entry one with other; bFirst=true switch to aCommand1 } -procedure ChangeMenu(MenuBar:PAdvancedMenuBar; bFirst:Boolean; - aCommand1: sw_word; Const aName1: String; aCommand2: sw_word; Const aName2: String); -var MenuItem : PMenuItem; -begin - MenuItem:=PAdvancedMenuBar(MenuBar)^.GetMenuItem(aCommand1); - if not assigned(MenuItem) then - MenuItem:=PAdvancedMenuBar(MenuBar)^.GetMenuItem(aCommand2); - if assigned(MenuItem) then - begin - If assigned(MenuItem^.Name) then - DisposeStr(MenuItem^.Name); - if bFirst then - begin - MenuItem^.Name:=NewStr(aName1); - MenuItem^.command:=aCommand1; - end - else - begin - MenuItem^.Name:=NewStr(aName2); - MenuItem^.command:=aCommand2; - end; - end; -end; - constructor TIDEApp.Init; var R: TRect; begin diff --git a/packages/ide/fpmrun.inc b/packages/ide/fpmrun.inc index b94baac713..e460520068 100644 --- a/packages/ide/fpmrun.inc +++ b/packages/ide/fpmrun.inc @@ -295,8 +295,25 @@ end; procedure TIDEApp.UpdateRunMenu(DebuggeeRunning : boolean); var MenuItem : PMenuItem; begin - ChangeMenu(PAdvancedMenuBar(MenuBar),DebuggeeRunning, - cmContinue,menu_run_continue,cmRun,menu_run_run); + MenuItem:=PAdvancedMenuBar(MenuBar)^.GetMenuItem(cmRun); + if not assigned(MenuItem) then + MenuItem:=PAdvancedMenuBar(MenuBar)^.GetMenuItem(cmContinue); + + if assigned(MenuItem) then + begin + If assigned(MenuItem^.Name) then + DisposeStr(MenuItem^.Name); + if DebuggeeRunning then + begin + MenuItem^.Name:=NewStr(menu_run_continue); + MenuItem^.command:=cmContinue; + end + else + begin + MenuItem^.Name:=NewStr(menu_run_run); + MenuItem^.command:=cmRun; + end; + end; MenuItem:=PAdvancedMenuBar(MenuBar)^.GetMenuItem(cmResetDebugger); if assigned(MenuItem) then MenuItem^.Disabled:=not DebuggeeRunning;