From ffa522c0ae254f293548ff5abf4a27763c0e6bc1 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 5 Dec 2009 10:17:51 +0000 Subject: [PATCH] IDE: reduced updating window menu on idle git-svn-id: trunk@22973 - --- ide/main.pp | 4 ++-- ide/mainbase.pas | 15 +++++++++++++-- ide/mainintf.pas | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ide/main.pp b/ide/main.pp index f80da47529..45d815b574 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1260,7 +1260,7 @@ begin // load package configs HelpBoss.LoadHelpOptions; - UpdateWindowMenu; + UpdateWindowMenu(true); end; procedure TMainIDE.StartIDE; @@ -2025,7 +2025,7 @@ begin // create new project DoNewProject(ProjectDescriptorApplication); - UpdateWindowMenu; + UpdateWindowMenu(true); // load the cmd line files if CmdLineFiles<>nil then begin diff --git a/ide/mainbase.pas b/ide/mainbase.pas index 4aacf5f660..c839bda703 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -85,6 +85,7 @@ type FToolStatus: TIDEToolStatus; protected FNeedUpdateHighlighters: boolean; + FLastWindowMenuUpdate: TDateTime; function CreateMenuSeparator : TMenuItem; procedure CreateMenuItem(Section: TIDEMenuSection; @@ -157,7 +158,7 @@ type function DoOpenMacroFile(Sender: TObject; const AFilename: string ): TModalResult; override; - procedure UpdateWindowMenu; override; + procedure UpdateWindowMenu(Immediately: boolean = false); override; procedure SetRecentSubMenu(Section: TIDEMenuSection; FileList: TStringList; OnClickEvent: TNotifyEvent); override; procedure UpdateHighlighters(Immediately: boolean = false); override; @@ -1013,7 +1014,9 @@ begin [ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofConvertMacros]); end; -procedure TMainIDEBase.UpdateWindowMenu; +procedure TMainIDEBase.UpdateWindowMenu(Immediately: boolean = false); +const + UpdatePause = 5/864000; // half a second function GetMenuItem(Index: Integer): TIDEMenuItem; inline; begin @@ -1029,7 +1032,15 @@ var i, ItemCount: Integer; CurMenuItem: TIDEMenuItem; AForm: TForm; + t: TDateTime; begin + t:=Now; + if (not Immediately) then begin + if (FLastWindowMenuUpdate<>0) and (t-FLastWindowMenuUpdatenil) and (SourceNotebook.Visible) then diff --git a/ide/mainintf.pas b/ide/mainintf.pas index 1df7e3dddc..e0ddbf3019 100644 --- a/ide/mainintf.pas +++ b/ide/mainintf.pas @@ -164,7 +164,7 @@ type function DoFixupComponentReferences(RootComponent: TComponent; OpenFlags: TOpenFlags): TModalResult; virtual; abstract; - procedure UpdateWindowMenu; virtual; abstract; + procedure UpdateWindowMenu(Immediately: boolean = false); virtual; abstract; procedure SaveEnvironment; virtual; abstract; procedure UpdateHighlighters(Immediately: boolean = false); virtual; abstract; procedure SetRecentSubMenu(Section: TIDEMenuSection; FileList: TStringList;