IdeDebugger: add Destroy-callback to TIDEBreakPointGroup

This commit is contained in:
Martin 2023-07-24 15:01:18 +02:00
parent cc98242bec
commit 25db56ee57
2 changed files with 42 additions and 1 deletions

View File

@ -19,6 +19,19 @@ uses
type
{ TFreeNotifyingGeneric }
generic TFreeNotifyingGeneric<_B: TObject> = class(_B)
private
FFreeNotificationList: TMethodList;
protected
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
public
//destructor Destroy; override;
procedure AddFreeNotification(ANotification: TNotifyEvent);
procedure RemoveFreeNotification(ANotification: TNotifyEvent);
end;
{ TFreeNotifyingObject }
TFreeNotifyingObject = class
@ -86,6 +99,33 @@ procedure NilThenReleaseRef(var ARefCountedObject; DebugIdAdr: Pointer; DebugIdT
{$ENDIF}
implementation
{ TFreeNotifyingGeneric }
procedure TFreeNotifyingGeneric.DoDestroy;
begin
if FFreeNotificationList <> nil then
FFreeNotificationList.CallNotifyEvents(Self);
inherited Destroy;
FreeAndNil(FFreeNotificationList);
end;
procedure TFreeNotifyingGeneric.AddFreeNotification(ANotification: TNotifyEvent
);
begin
if FFreeNotificationList = nil then
FFreeNotificationList := TMethodList.Create;
FFreeNotificationList.Add(TMethod(ANotification));
end;
procedure TFreeNotifyingGeneric.RemoveFreeNotification(
ANotification: TNotifyEvent);
begin
if FFreeNotificationList = nil then
exit;
FFreeNotificationList.Remove(TMethod(ANotification));
end;
{$IFDEF WITH_REFCOUNT_DEBUG}
uses LazLoggerBase;
{$IFDEF WITH_REFCOUNT_LEAK_DEBUG}

View File

@ -421,7 +421,7 @@ type
{ TIDEBreakPointGroup }
TIDEBreakPointGroup = class(TCollectionItem)
TIDEBreakPointGroup = class(specialize TFreeNotifyingGeneric<TCollectionItem>)
private
FEnabled: Boolean;
FInitialEnabled: Boolean;
@ -6421,6 +6421,7 @@ begin
for n := FReferences.Count - 1 downto 0 do
TIDEBreakPointGroupList(FReferences[n]).Remove(Self);
DoDestroy;
inherited Destroy;
FreeAndNil(FBreakpoints);
FreeAndNil(FReferences);