From e022bfe9e8f105b0c3db4357b0776ee48d7027b9 Mon Sep 17 00:00:00 2001 From: ondrej Date: Fri, 30 Oct 2015 12:38:55 +0000 Subject: [PATCH] IDE: fixed AV in Editor->FileSettings->Encoding. Issue #28930 git-svn-id: trunk@50200 - --- components/ideintf/idecommands.pas | 16 +++++++++++++--- components/ideintf/menuintf.pas | 22 ---------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/components/ideintf/idecommands.pas b/components/ideintf/idecommands.pas index 04d2c69f95..5718b63b15 100644 --- a/components/ideintf/idecommands.pas +++ b/components/ideintf/idecommands.pas @@ -813,7 +813,7 @@ procedure CreateStandardIDECommandScopes; function CompareIDEShortCuts(Data1, Data2: Pointer): integer; function CompareIDEShortCutKey1s(Data1, Data2: Pointer): integer; - +function CompareEvents(Event1, Event2: TNotifyEvent): Integer; function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean; function IDECommandToIdent(Cmd: longint; var Ident: string): boolean; procedure GetIDEEditorCommandValues(Proc: TGetStrProc); @@ -1287,7 +1287,7 @@ procedure TIDECommand.SetOnExecute(const aOnExecute: TNotifyEvent); var xUser: TIDESpecialCommand; begin - if FOnExecute = aOnExecute then Exit; + if CompareEvents(FOnExecute, aOnExecute) = 0 then Exit; FOnExecute := aOnExecute; for xUser in FUsers do xUser.OnClick := FOnExecute; @@ -1694,7 +1694,7 @@ end; procedure TIDESpecialCommand.SetOnClickMethod(const aOnClick: TNotifyEvent); begin - if FOnClickMethod = aOnClick then Exit; + if CompareEvents(FOnClickMethod, aOnClick) = 0 then Exit; FOnClickMethod := aOnClick; if FCommand<> nil then FCommand.OnExecute:=aOnClick; @@ -2180,6 +2180,16 @@ const (Value: ecIdePSyncroEdSelStart; Name: 'ecIdePSyncroEdSelStart') ); +function CompareEvents(Event1, Event2: TNotifyEvent): Integer; +var + xMethod1: TMethod absolute Event1; + xMethod2: TMethod absolute Event2; +begin + Result := ComparePointers(xMethod1.Code, xMethod2.Code); + if Result<>0 then Exit; + Result := ComparePointers(xMethod1.Data, xMethod2.Data); +end; + function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean; begin Result := IdentToInt(Ident, Cmd, IDEEditorCommandStrs); diff --git a/components/ideintf/menuintf.pas b/components/ideintf/menuintf.pas index 9f280a9fec..6a47470078 100644 --- a/components/ideintf/menuintf.pas +++ b/components/ideintf/menuintf.pas @@ -209,8 +209,6 @@ type procedure SetRightJustify(const AValue: boolean); virtual; procedure SetShowAlwaysCheckable(const AValue: boolean); virtual; procedure SetMenuItem(const AValue: TMenuItem); override; - procedure SetOnClickMethod(const AValue: TNotifyEvent); override; - procedure SetOnClickProc(const AValue: TNotifyProcedure); override; public property AutoCheck: boolean read FAutoCheck write SetAutoCheck default False; property Default: Boolean read FDefault write SetDefault default False; @@ -1676,26 +1674,6 @@ begin end; end; -procedure TIDEMenuCommand.SetOnClickMethod(const AValue: TNotifyEvent); -var - OldClick: TNotifyEvent; -begin - OldClick:=OnClick; - inherited SetOnClickMethod(AValue); - if Assigned(Command) and (Command.OnExecute = OldClick) then - Command.OnExecute := OnClick; -end; - -procedure TIDEMenuCommand.SetOnClickProc(const AValue: TNotifyProcedure); -var - OldClick: TNotifyProcedure; -begin - OldClick:=OnClickProc; - inherited SetOnClickProc(AValue); - if Assigned(Command) and (Command.OnExecuteProc = OldClick) then - Command.OnExecuteProc := OnClickProc; -end; - { TIDEMenuRoots } function TIDEMenuRoots.GetItems(Index: integer): TIDEMenuSection;