From 4e939b31dd6e1bd62a410ae482117876b440bab5 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Sun, 2 Feb 2025 12:09:48 +0100 Subject: [PATCH] Replace locally implement operator overload for method comparison by already available SameMethod. Proposed by n7800 in MR !431 --- components/tachart/tachartaxis.pas | 6 +++--- components/tachart/tachartlistbox.pas | 6 +++--- components/tachart/tachartutils.pas | 10 ++-------- components/tachart/tacustomseries.pas | 6 +++--- components/tachart/tadbsource.pas | 4 ++-- components/tachart/tafuncseries.pas | 8 ++++---- components/tachart/tagraph.pas | 24 ++++++++++++------------ components/tachart/talegend.pas | 6 +++--- components/tachart/taradialseries.pas | 4 ++-- components/tachart/taseries.pas | 10 +++++----- components/tachart/tasources.pas | 4 ++-- components/tachart/tatextelements.pas | 4 ++-- components/tachart/tatransformations.pas | 6 +++--- lcl/shellctrls.pas | 12 +++++------- 14 files changed, 51 insertions(+), 59 deletions(-) diff --git a/components/tachart/tachartaxis.pas b/components/tachart/tachartaxis.pas index f62e419ade..1252f4abf1 100644 --- a/components/tachart/tachartaxis.pas +++ b/components/tachart/tachartaxis.pas @@ -301,7 +301,7 @@ type implementation uses - LResources, Math, PropEdits, + LResources, Math, LazMethodList, PropEdits, TAChartStrConsts, TAGeometry, TAMath; var @@ -1182,14 +1182,14 @@ end; procedure TChartAxis.SetOnGetMarkText(AValue: TChartGetAxisMarkTextEvent); begin - if TMethod(FOnGetMarkText) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetMarkText), TMethod(AValue)) then exit; FOnGetMarkText := AValue; StyleChanged(Self); end; procedure TChartAxis.SetOnMarkToText(AValue: TChartAxisMarkToTextEvent); begin - if TMethod(FOnMarkToText) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnMarkToText), TMethod(AValue)) then exit; FOnMarkToText := AValue; StyleChanged(Self); end; diff --git a/components/tachart/tachartlistbox.pas b/components/tachart/tachartlistbox.pas index 6994797b15..5c4ba77fb6 100644 --- a/components/tachart/tachartlistbox.pas +++ b/components/tachart/tachartlistbox.pas @@ -31,7 +31,7 @@ interface uses Classes, Controls, SysUtils, Types, Math, - StdCtrls, Graphics, LCLIntf, LCLType, Themes, + StdCtrls, Graphics, LCLIntf, LCLType, LazMethodList, Themes, IntegerList, LazUTF8, TAChartUtils, TACustomSeries, TALegend, TAGraph, TACustomSource, TADrawerCanvas, TADrawUtils, TAEnumerators, TAGeometry; @@ -732,14 +732,14 @@ end; procedure TChartListbox.SetOnAddSeries(AValue: TChartListboxAddSeriesEvent); begin - if TMethod(FOnAddSeries) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAddSeries), TMethod(AValue)) then exit; FOnAddSeries := AValue; Populate; end; procedure TChartListbox.SetOnPopulate(AValue: TNotifyEvent); begin - if TMethod(FOnPopulate) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnPopulate), TMethod(AValue)) then exit; FOnPopulate := AValue; Populate; end; diff --git a/components/tachart/tachartutils.pas b/components/tachart/tachartutils.pas index 0e743446ab..1bb7e15017 100644 --- a/components/tachart/tachartutils.pas +++ b/components/tachart/tachartutils.pas @@ -397,8 +397,6 @@ procedure UpdateMinMax(AValue: Integer; var AMin, AMax: Integer); overload; function WeightedAverage(AX1, AX2, ACoeff: Double): Double; inline; -operator =(const A, B: TMethod): Boolean; overload; inline; - var DrawData: TDrawDataRegistry; ShowMessageProc: TShowMessageProc; @@ -407,7 +405,7 @@ var implementation uses - StrUtils, TypInfo, TAChartStrConsts; + StrUtils, TypInfo, LazMethodList, TAChartStrConsts; function BoundsSize(ALeft, ATop: Integer; ASize: TSize): TRect; inline; begin @@ -682,10 +680,6 @@ begin Result := AX1 * (1 - ACoeff) + AX2 * ACoeff; end; -operator = (const A, B: TMethod): Boolean; -begin - Result := (A.Code = B.Code) and (A.Data = B.Data); -end; { THistory } @@ -870,7 +864,7 @@ end; procedure TIntervalList.SetOnChange(AValue: TNotifyEvent); begin - if TMethod(FOnChange) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnChange), TMethod(AValue)) then exit; FOnChange := AValue; end; diff --git a/components/tachart/tacustomseries.pas b/components/tachart/tacustomseries.pas index a72d23ddde..3eaa59e0e7 100644 --- a/components/tachart/tacustomseries.pas +++ b/components/tachart/tacustomseries.pas @@ -370,7 +370,7 @@ type implementation uses - Math, PropEdits, StrUtils, LResources, Types, GraphUtil, + Math, PropEdits, StrUtils, LResources, LazMethodList, Types, GraphUtil, TAChartStrConsts, TAGeometry, TAMath; function CreateLazIntfImage( @@ -1118,14 +1118,14 @@ end; procedure TChartSeries.SetOnGetMark(AValue: TChartGetMarkEvent); begin - if TMethod(FOnGetMark) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetMark), TMethod(AValue)) then exit; FOnGetMark := AValue; UpdateParentChart; end; procedure TChartSeries.SetOnGetMarkText(AValue: TChartGetMarkTextEvent); begin - if TMethod(FOnGetMarkText) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetMarkText), TMethod(AValue)) then exit; FOnGetMarkText := AValue; UpdateParentChart; end; diff --git a/components/tachart/tadbsource.pas b/components/tachart/tadbsource.pas index e1be2b940d..619f8cc1a0 100644 --- a/components/tachart/tadbsource.pas +++ b/components/tachart/tadbsource.pas @@ -82,7 +82,7 @@ procedure Register; implementation uses - Math, SysUtils, DateUtils, TAMath; + Math, SysUtils, DateUtils, LazMethodList, TAMath; type @@ -345,7 +345,7 @@ end; procedure TDbChartSource.SetOnGetItem(AValue: TDbChartSourceGetItemEvent); begin - if TMethod(FOnGetItem) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetItem), TMethod(AValue)) then exit; FOnGetItem := AValue; Reset; end; diff --git a/components/tachart/tafuncseries.pas b/components/tachart/tafuncseries.pas index fc48229e7b..30ca01dad1 100644 --- a/components/tachart/tafuncseries.pas +++ b/components/tachart/tafuncseries.pas @@ -499,7 +499,7 @@ implementation uses ipf, - GraphType, GraphUtil, Math, spe, StrUtils, SysUtils, + GraphType, GraphUtil, Math, spe, StrUtils, SysUtils, LazMethodList, TAChartStrConsts, TAGeometry, TAGraph, TAMath; const @@ -776,7 +776,7 @@ end; procedure TFuncSeries.SetOnCalculate(AValue: TFuncCalculateEvent); begin - if TMethod(FOnCalculate) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit; FOnCalculate := AValue; UpdateParentChart; end; @@ -897,7 +897,7 @@ end; procedure TParametricCurveSeries.SetOnCalculate( AValue: TParametricCurveCalculateEvent); begin - if TMethod(FOnCalculate) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit; FOnCalculate := AValue; UpdateParentChart; end; @@ -2879,7 +2879,7 @@ end; procedure TColorMapSeries.SetOnCalculate(AValue: TFuncCalculate3DEvent); begin - if TMethod(FOnCalculate) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit; FOnCalculate := AValue; InvalidateBufferImage; UpdateParentChart; diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index ba2eb76acf..ee6603ba29 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -525,7 +525,7 @@ implementation uses Math, Types, - Clipbrd, Dialogs, LResources, + Clipbrd, Dialogs, LResources, LazMethodList, TADrawerCanvas, TAGeometry, TAMath, TAStyles; const @@ -1835,77 +1835,77 @@ end; procedure TChart.SetOnAfterDraw(AValue: TChartDrawEvent); begin - if TMethod(FOnAfterDraw) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAfterDraw), TMethod(AValue)) then exit; FOnAfterDraw := AValue; StyleChanged(Self); end; procedure TChart.SetOnAfterCustomDrawBackground(AValue: TChartAfterCustomDrawEvent); begin - if TMethod(FOnAfterCustomDrawBackground) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAfterCustomDrawBackground), TMethod(AValue)) then exit; FOnAfterCustomDrawBackground := AValue; StyleChanged(Self); end; procedure TChart.SetOnAfterCustomDrawBackWall(AValue: TChartAfterCustomDrawEvent); begin - if TMethod(FOnAfterCustomDrawBackWall) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAfterCustomDrawBackWall), TMethod(AValue)) then exit; FOnAfterCustomDrawBackWall := AValue; StyleChanged(Self); end; procedure TChart.SetOnAfterDrawBackground(AValue: TChartAfterDrawEvent); begin - if TMethod(FOnAfterDrawBackground) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAfterDrawBackground), TMethod(AValue)) then exit; FOnAfterDrawBackground := AValue; StyleChanged(Self); end; procedure TChart.SetOnAfterDrawBackWall(AValue: TChartAfterDrawEvent); begin - if TMethod(FOnAfterDrawBackWall) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAfterDrawBackWall), TMethod(AValue)) then exit; FOnAfterDrawBackWall := AValue; StyleChanged(Self); end; procedure TChart.SetOnBeforeCustomDrawBackground(AValue: TChartBeforeCustomDrawEvent); begin - if TMethod(FOnBeforeCustomDrawBackground) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnBeforeCustomDrawBackground), TMethod(AValue)) then exit; FOnBeforeCustomDrawBackground := AValue; StyleChanged(Self); end; procedure TChart.SetOnBeforeCustomDrawBackWall(AValue: TChartBeforeCustomDrawEvent); begin - if TMethod(FOnBeforeCustomDrawBackWall) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnBeforeCustomDrawBackWall), TMethod(AValue)) then exit; FOnBeforeCustomDrawBackWall := AValue; StyleChanged(Self); end; procedure TChart.SetOnBeforeDrawBackground(AValue: TChartBeforeDrawEvent); begin - if TMethod(FOnBeforeDrawBackground) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnBeforeDrawBackground), TMethod(AValue)) then exit; FOnBeforeDrawBackground := AValue; StyleChanged(Self); end; procedure TChart.SetOnBeforeDrawBackWall(AValue: TChartBeforeDrawEvent); begin - if TMethod(FOnBeforeDrawBackWall) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnBeforeDrawBackWall), TMethod(AValue)) then exit; FOnBeforeDrawBackWall := AValue; StyleChanged(Self); end; procedure TChart.SetOnChartPaint(AValue: TChartPaintEvent); begin - if TMethod(FOnChartPaint) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnChartPaint), TMethod(AValue)) then exit; FOnChartPaint := AValue; StyleChanged(Self); end; procedure TChart.SetOnDrawLegend(AValue: TChartDrawLegendEvent); begin - if TMethod(FOnDrawLegend) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnDrawLegend), TMethod(AValue)) then exit; FOnDrawLegend := AValue; StyleChanged(self); end; diff --git a/components/tachart/talegend.pas b/components/tachart/talegend.pas index c6b850cabe..64ca3f4466 100644 --- a/components/tachart/talegend.pas +++ b/components/tachart/talegend.pas @@ -339,7 +339,7 @@ type implementation uses - Math, PropEdits, Types, LResources, + Math, PropEdits, Types, LResources, LazMethodList, TADrawerCanvas, TAGeometry; const @@ -1206,14 +1206,14 @@ end; procedure TChartSeriesLegend.SetOnDraw(AValue: TLegendItemDrawEvent); begin - if TMethod(FOnDraw) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnDraw), TMethod(AValue)) then exit; FOnDraw := AValue; StyleChanged(Self); end; procedure TChartSeriesLegend.SetOnCreate(AValue: TLegendItemCreateEvent); begin - if TMethod(FOnCreate) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCreate), TMethod(AValue)) then exit; FOnCreate := AValue; StyleChanged(Self); end; diff --git a/components/tachart/taradialseries.pas b/components/tachart/taradialseries.pas index fe5a226773..99ade40afc 100644 --- a/components/tachart/taradialseries.pas +++ b/components/tachart/taradialseries.pas @@ -220,7 +220,7 @@ type implementation uses - Math, + Math, LazMethodList, TAChartStrConsts, TATypes, TACustomSource, TAGeometry, TAGraph; const @@ -901,7 +901,7 @@ end; procedure TCustomPieSeries.SetOnCustomDrawPie(AValue: TCustomDrawPieEvent); begin - if TMethod(FOnCustomDrawPie) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCustomDrawPie), TMethod(AValue)) then exit; FOnCustomDrawPie := AValue; UpdateParentChart; end; diff --git a/components/tachart/taseries.pas b/components/tachart/taseries.pas index d61ca49379..2316d59a37 100644 --- a/components/tachart/taseries.pas +++ b/components/tachart/taseries.pas @@ -410,7 +410,7 @@ type implementation uses - {GraphMath,} GraphType, IntfGraphics, LResources, Math, PropEdits, SysUtils, + GraphType, IntfGraphics, LResources, LazMethodList, Math, PropEdits, SysUtils, TAChartStrConsts, TADrawerCanvas, TAGeometry, TACustomSource, TAGraph, TAMath, TAStyles; @@ -1898,14 +1898,14 @@ end; procedure TBarSeries.SetOnBeforeDrawBar(AValue: TBeforeDrawBarEvent); begin - if TMethod(FOnBeforeDrawBar) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnBeforeDrawBar), TMethod(AValue)) then exit; FOnBeforeDrawBar := AValue; UpdateParentChart; end; procedure TBarSeries.SetOnCustomDrawBar(AValue: TCustomDrawBarEvent); begin - if TMethod(FOnCustomDrawBar) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnCustomDrawBar), TMethod(AValue)) then exit; FOnCustomDrawBar := AValue; UpdateParentChart; end; @@ -2520,14 +2520,14 @@ end; procedure TUserDrawnSeries.SetOnDraw(AValue: TSeriesDrawEvent); begin - if TMethod(FOnDraw) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnDraw), TMethod(AValue)) then exit; FOnDraw := AValue; UpdateParentChart; end; procedure TUserDrawnSeries.SetOnGetBounds(AValue: TSeriesGetBoundsEvent); begin - if TMethod(FOnGetBounds) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetBounds), TMethod(AValue)) then exit; FOnGetBounds := AValue; UpdateParentChart; end; diff --git a/components/tachart/tasources.pas b/components/tachart/tasources.pas index a394c1c89b..53870246ff 100644 --- a/components/tachart/tasources.pas +++ b/components/tachart/tasources.pas @@ -304,7 +304,7 @@ procedure Register; implementation uses - Math, StrUtils, SysUtils, TAMath, TAChartStrConsts; + Math, StrUtils, SysUtils, LazMethodList, TAMath, TAChartStrConsts; type TCustomChartSourceAccess = class(TCustomChartSource); @@ -1485,7 +1485,7 @@ end; procedure TUserDefinedChartSource.SetOnGetChartDataItem( AValue: TGetChartDataItemEvent); begin - if TMethod(FOnGetChartDataItem) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetChartDataItem), TMethod(AValue)) then exit; FOnGetChartDataItem := AValue; Reset; end; diff --git a/components/tachart/tatextelements.pas b/components/tachart/tatextelements.pas index 682dbb0c63..c5c345e1c3 100644 --- a/components/tachart/tatextelements.pas +++ b/components/tachart/tatextelements.pas @@ -15,7 +15,7 @@ unit TATextElements; interface uses - Classes, Graphics, Types, + Classes, Graphics, Types, LazMethodList, TAChartUtils, TADrawUtils, TATypes, // Workaround for issue #22850. @@ -585,7 +585,7 @@ end; procedure TChartTextElement.SetOnGetShape(AValue: TChartGetShapeEvent); begin - if TMethod(FOnGetShape) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGetShape), TMethod(AValue)) then exit; FOnGetShape := AValue; StyleChanged(Self); end; diff --git a/components/tachart/tatransformations.pas b/components/tachart/tatransformations.pas index a04780412d..7ca580bc45 100644 --- a/components/tachart/tatransformations.pas +++ b/components/tachart/tatransformations.pas @@ -202,7 +202,7 @@ type implementation uses - ComponentEditors, Forms, Math, PropEdits, + ComponentEditors, Forms, Math, LazMethodList, PropEdits, TAChartStrConsts, TAMath, TASubcomponentsEditor; type @@ -797,14 +797,14 @@ end; procedure TUserDefinedAxisTransform.SetOnAxisToGraph(AValue: TTransformEvent); begin - if TMethod(FOnAxisToGraph) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnAxisToGraph), TMethod(AValue)) then exit; FOnAxisToGraph := AValue; Changed; end; procedure TUserDefinedAxisTransform.SetOnGraphToAxis(AValue: TTransformEvent); begin - if TMethod(FOnGraphToAxis) = TMethod(AValue) then exit; + if SameMethod(TMethod(FOnGraphToAxis), TMethod(AValue)) then exit; FOnGraphToAxis := AValue; Changed; end; diff --git a/lcl/shellctrls.pas b/lcl/shellctrls.pas index fad7553c1f..5d076ec8f0 100644 --- a/lcl/shellctrls.pas +++ b/lcl/shellctrls.pas @@ -422,7 +422,8 @@ procedure Register; implementation -uses WSShellCtrls +uses + WSShellCtrls, LazMethodList {$ifdef windows} ,Windows, ShellApi {$endif}; @@ -465,10 +466,6 @@ begin Result := Format(sShellCtrlsGB, [Format('%.1n', [AFileSize / ONE_GB])]); end; -operator = (const A, B: TMethod): Boolean; -begin - Result := (A.Code = B.Code) and (A.Data = B.Data); -end; { TShellListItem } @@ -701,7 +698,7 @@ var RootNode: TTreeNode; CurrPath: String; begin - if TMethod(AValue) = TMethod(FOnSortCompare) then + if SameMethod(TMethod(AValue), TMethod(FOnSortCompare)) then Exit; FOnSortCompare := AValue; @@ -1776,7 +1773,8 @@ end; procedure TCustomShellListView.SetOnSortCompare(AValue: TFileItemCompareEvent); begin - if TMethod(AValue) = TMethod(FOnSortCompare) then Exit; + if SameMethod(TMethod(AValue), TMethod(FOnSortCompare)) then + Exit; FOnSortCompare:=AValue; Clear; Items.Clear;