IDE, Debugger: fixed dangling object. When project was changed then FCurrentDebuggerPropertiesConfig was freed as part of the list, but the field was left dangling.

This commit is contained in:
Martin 2024-12-28 18:28:31 +01:00
parent 106a194305
commit 924ce02d50
3 changed files with 14 additions and 1 deletions

View File

@ -69,6 +69,7 @@ type
function GetOpt(Index: Integer): TDebuggerPropertiesConfig;
public
constructor Create;
procedure Clear; override;
function EntryByName(AConfName, AConfClass: String): TDebuggerPropertiesConfig;
function EntryByUid(AnUid: String): TDebuggerPropertiesConfig;
@ -568,6 +569,12 @@ begin
end;
procedure TDebuggerPropertiesConfigListBase.Clear;
begin
inherited Clear;
FCurrentDebuggerPropertiesConfig := nil;
end;
function TDebuggerPropertiesConfigListBase.EntryByName(AConfName,
AConfClass: String): TDebuggerPropertiesConfig;
var

View File

@ -44,7 +44,7 @@ type
FValueFormatterConfig: TIdeDbgValueFormatterSelectorList;
function GetCurrentDebuggerBackend: String;
procedure SetDebuggerBackend(AValue: String);
procedure SetProject(AValue: TProject);
procedure SetProject(AValue: TProject); override;
procedure SetStoreDebuggerClassConfInSession(AValue: boolean);
procedure SetStoreBackendConverterConfigInSession(AValue: boolean);
procedure SetStoreDisplayFormatConfigsInSession(AValue: boolean);
@ -169,6 +169,8 @@ procedure TProjectDebugLink.SetProject(AValue: TProject);
begin
// A new project can have the same address as a previous freed project and this test
//if FProject = AValue then Exit; // would prevent updating FProject.DebuggerLink.
if FProject <> AValue then
Clear;
FProject := AValue;
if Assigned(FProject) then
FProject.DebuggerLink := Self;

View File

@ -726,6 +726,7 @@ type
private
protected
procedure Clear; virtual; abstract;
procedure SetProject(AValue: TProject); virtual; abstract;
procedure BeforeReadProject; virtual; abstract;
procedure AfterReadProject; virtual; abstract;
procedure LoadFromLPI(aXMLConfig: TRttiXMLConfig; Path: string); virtual; abstract;
@ -735,6 +736,7 @@ type
public
//constructor Create;
//destructor Destroy; override;
property Project: TProject write SetProject;
end;
{ TProject }
@ -2933,6 +2935,8 @@ begin
FDefineTemplates.Active := False;
ActiveBuildMode:=nil;
Clear;
if Assigned(FDebuggerLink) then
FDebuggerLink.Project := nil;
FreeThenNil(FIDEOptions);
FreeAndNil(FBuildModesBackup);
FreeAndNil(FBuildModes);