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 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 }
TFreeNotifyingObject = class TFreeNotifyingObject = class
@ -86,6 +99,33 @@ procedure NilThenReleaseRef(var ARefCountedObject; DebugIdAdr: Pointer; DebugIdT
{$ENDIF} {$ENDIF}
implementation 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} {$IFDEF WITH_REFCOUNT_DEBUG}
uses LazLoggerBase; uses LazLoggerBase;
{$IFDEF WITH_REFCOUNT_LEAK_DEBUG} {$IFDEF WITH_REFCOUNT_LEAK_DEBUG}

View File

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