DebuggerOptions: TDebuggerPropertiesConfig removed MarkAsDeleted workaround.

This commit is contained in:
Martin 2023-01-01 13:16:01 +01:00
parent 8ddfc51b46
commit 8f2367727a
5 changed files with 29 additions and 65 deletions

View File

@ -297,9 +297,9 @@ begin
exit; exit;
i := FCopiedDbgPropertiesConfigList.IndexOfObject(FSelectedDbgPropertiesConfig); i := FCopiedDbgPropertiesConfigList.IndexOfObject(FSelectedDbgPropertiesConfig);
FSelectedDbgPropertiesConfig.MarkAsDeleted; if i >= 0 then
FCopiedDbgPropertiesConfigList.Delete(i);
FSelectedDbgPropertiesConfig := nil; FSelectedDbgPropertiesConfig := nil;
FCopiedDbgPropertiesConfigList[i] := ''; // remove from named part of list
FillNameDropDown; FillNameDropDown;
UpdateDebuggerClassDropDown; UpdateDebuggerClassDropDown;
@ -522,7 +522,6 @@ begin
while i >= 0 do while i >= 0 do
if (FCopiedDbgPropertiesConfigList[i] <> '') or if (FCopiedDbgPropertiesConfigList[i] <> '') or
(FCopiedDbgPropertiesConfigList.Opt[i].DebuggerClass <> SelectedDebuggerClass) or (FCopiedDbgPropertiesConfigList.Opt[i].DebuggerClass <> SelectedDebuggerClass) or
(FCopiedDbgPropertiesConfigList.Opt[i].IsDeleted) or
(FCopiedDbgPropertiesConfigList.Opt[i] = FSelectedDbgPropertiesConfig) (FCopiedDbgPropertiesConfigList.Opt[i] = FSelectedDbgPropertiesConfig)
then then
dec(i) dec(i)
@ -553,7 +552,7 @@ end;
procedure TDebuggerClassOptionsFrame.ClearDbgProperties; procedure TDebuggerClassOptionsFrame.ClearDbgProperties;
begin begin
PropertyGrid.Selection.Clear; PropertyGrid.Selection.Clear;
FCopiedDbgPropertiesConfigList.ClearAll; FCopiedDbgPropertiesConfigList.Clear;
DoModifiedDbgPropertiesCountChanged; DoModifiedDbgPropertiesCountChanged;
end; end;
@ -569,8 +568,7 @@ begin
{$ENDIF} {$ENDIF}
tbDropMenu.Items.Clear; tbDropMenu.Items.Clear;
for i := 0 to FCopiedDbgPropertiesConfigList.Count - 1 do for i := 0 to FCopiedDbgPropertiesConfigList.Count - 1 do
if (not FCopiedDbgPropertiesConfigList.Opt[i].IsDeleted) and if (FCopiedDbgPropertiesConfigList.Opt[i].IsLoaded)
(FCopiedDbgPropertiesConfigList.Opt[i].IsLoaded)
then begin then begin
m := TMenuItem.Create(tbDropMenu); m := TMenuItem.Create(tbDropMenu);
m.Caption := FCopiedDbgPropertiesConfigList.Opt[i].DisplayName; m.Caption := FCopiedDbgPropertiesConfigList.Opt[i].DisplayName;
@ -592,7 +590,7 @@ begin
lblWarningProject.Visible := not ( lblWarningProject.Visible := not (
(Project1.DebuggerBackend = FSelectedDbgPropertiesConfig.UID) or (Project1.DebuggerBackend = FSelectedDbgPropertiesConfig.UID) or
(Project1.DebuggerBackend = 'IDE') or (Project1.DebuggerBackend = 'IDE') or
( (Project1.DebuggerBackend = '') and (Project1.DebuggerPropertiesConfigList.CountWithoutDeleted = 0) ) ( (Project1.DebuggerBackend = '') and (Project1.DebuggerPropertiesConfigList.Count = 0) )
); );
end; end;
@ -694,7 +692,7 @@ begin
ClearDbgProperties; ClearDbgProperties;
FDebuggerFileHistory.Clear; FDebuggerFileHistory.Clear;
FCopiedDbgPropertiesConfigList.ClearAll; FCopiedDbgPropertiesConfigList.Clear;
for i := 0 to ADbgConf.Count - 1 do for i := 0 to ADbgConf.Count - 1 do
FCopiedDbgPropertiesConfigList.AddObject(ADbgConf[i], FCopiedDbgPropertiesConfigList.AddObject(ADbgConf[i],
TDebuggerPropertiesConfig.CreateCopy(ADbgConf.Opt[i], True, True) ); TDebuggerPropertiesConfig.CreateCopy(ADbgConf.Opt[i], True, True) );
@ -728,7 +726,7 @@ begin
// DebuggerSearchPath := TrimSearchPath(txtAdditionalPath.Text,''); // DebuggerSearchPath := TrimSearchPath(txtAdditionalPath.Text,'');
ADbgConf.ClearAll; ADbgConf.Clear;
for i := 0 to FCopiedDbgPropertiesConfigList.Count - 1 do for i := 0 to FCopiedDbgPropertiesConfigList.Count - 1 do
ADbgConf.AddObject(FCopiedDbgPropertiesConfigList[i], ADbgConf.AddObject(FCopiedDbgPropertiesConfigList[i],
TDebuggerPropertiesConfig.CreateCopy(FCopiedDbgPropertiesConfigList.Opt[i], True, True) ); TDebuggerPropertiesConfig.CreateCopy(FCopiedDbgPropertiesConfigList.Opt[i], True, True) );

View File

@ -133,13 +133,13 @@ begin
lblResolvedDebuggerHint.Visible := False; lblResolvedDebuggerHint.Visible := False;
case FDebuggerBackendIdx of case FDebuggerBackendIdx of
DBG_IDX_PROJECT: begin DBG_IDX_PROJECT: begin
if FClassOpts.ModifiedDbgPropertiesConfigList.CountWithoutDeleted = 0 then begin if FClassOpts.ModifiedDbgPropertiesConfigList.Count = 0 then begin
lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe; lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe;
lblResolvedDebuggerHint.Visible := True; lblResolvedDebuggerHint.Visible := True;
end; end;
end; end;
DBG_IDX_IDE: begin DBG_IDX_IDE: begin
if FClassOpts.ModifiedDbgPropertiesConfigList.CountWithoutDeleted > 0 then begin if FClassOpts.ModifiedDbgPropertiesConfigList.Count > 0 then begin
lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe; lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe;
lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings; lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings;
lblResolvedDebuggerHint.Visible := True; lblResolvedDebuggerHint.Visible := True;
@ -147,12 +147,12 @@ begin
end; end;
DBG_IDX_UNKNOWN: begin DBG_IDX_UNKNOWN: begin
lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe; lblResolvedDebuggerHint.Caption := drsUsingIDEDefaultDebuggerSe;
if FClassOpts.ModifiedDbgPropertiesConfigList.CountWithoutDeleted > 0 then if FClassOpts.ModifiedDbgPropertiesConfigList.Count > 0 then
lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings; lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings;
lblResolvedDebuggerHint.Visible := True; lblResolvedDebuggerHint.Visible := True;
end; end;
otherwise begin otherwise begin
if FClassOpts.ModifiedDbgPropertiesConfigList.CountWithoutDeleted > 0 then begin if FClassOpts.ModifiedDbgPropertiesConfigList.Count > 0 then begin
lblResolvedDebuggerHint.Caption := drsUsingSelectedIDEDebuggerS; lblResolvedDebuggerHint.Caption := drsUsingSelectedIDEDebuggerS;
lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings; lblResolvedDebuggerHint.Caption := lblResolvedDebuggerHint.Caption + drsIgnoringProjectDebuggerSettings;
lblResolvedDebuggerHint.Visible := True; lblResolvedDebuggerHint.Visible := True;

View File

@ -15,7 +15,7 @@ type
TDebuggerPropertiesConfig = class(TPersistent) TDebuggerPropertiesConfig = class(TPersistent)
private private
FFLags: set of (dpcLoaded, dpcDeleted); FFLags: set of (dpcLoaded);
FActive: Boolean; FActive: Boolean;
FConfigClass: String; FConfigClass: String;
FConfigClassInOldXml: String; // The ConfigClass in the xml file. In case the class in memory is changed FConfigClassInOldXml: String; // The ConfigClass in the xml file. In case the class in memory is changed
@ -41,9 +41,7 @@ type
function DisplayName: String; function DisplayName: String;
function NeedsExePath: Boolean; function NeedsExePath: Boolean;
procedure ChangeDebuggerClass(ADebuggerClass: TDebuggerClass; ACopyPropValues: Boolean = True); procedure ChangeDebuggerClass(ADebuggerClass: TDebuggerClass; ACopyPropValues: Boolean = True);
procedure MarkAsDeleted;
function IsLoaded: Boolean; // The class for the debugger was found function IsLoaded: Boolean; // The class for the debugger was found
function IsDeleted: Boolean;
function DebugText: String; function DebugText: String;
procedure DeleteFromOldXml(AXMLCfg: TRttiXMLConfig; APath: String); procedure DeleteFromOldXml(AXMLCfg: TRttiXMLConfig; APath: String);
@ -75,12 +73,11 @@ type
function GetOpt(Index: Integer): TDebuggerPropertiesConfig; function GetOpt(Index: Integer): TDebuggerPropertiesConfig;
procedure SetCurrentDebuggerPropertiesOpt(AValue: TDebuggerPropertiesConfig); procedure SetCurrentDebuggerPropertiesOpt(AValue: TDebuggerPropertiesConfig);
public public
constructor Create;
procedure LoadFromXml(AXMLCfg: TRttiXMLConfig; APath: String); procedure LoadFromXml(AXMLCfg: TRttiXMLConfig; APath: String);
procedure LoadFromOldXml(AXMLCfg: TRttiXMLConfig; APath: String; AnOldFileNamePath: String = ''); procedure LoadFromOldXml(AXMLCfg: TRttiXMLConfig; APath: String; AnOldFileNamePath: String = '');
procedure SaveToXml(AXMLCfg: TRttiXMLConfig; APath: String; AForceSaveEmpty: Boolean = False); procedure SaveToXml(AXMLCfg: TRttiXMLConfig; APath: String; AForceSaveEmpty: Boolean = False);
procedure ClearAll;
function CountWithoutDeleted: Integer;
function EntryByName(AConfName, AConfClass: String): TDebuggerPropertiesConfig; function EntryByName(AConfName, AConfClass: String): TDebuggerPropertiesConfig;
function EntryByUid(AnUid: String): TDebuggerPropertiesConfig; function EntryByUid(AnUid: String): TDebuggerPropertiesConfig;
property Opt[Index: Integer]: TDebuggerPropertiesConfig read GetOpt; property Opt[Index: Integer]: TDebuggerPropertiesConfig read GetOpt;
@ -308,13 +305,11 @@ begin
FDebuggerFilename := ASource.FDebuggerFilename; FDebuggerFilename := ASource.FDebuggerFilename;
FFLags := ASource.FFLags; FFLags := ASource.FFLags;
if not IsDeleted then begin FreeAndNil(FDebuggerProperties);
FreeAndNil(FDebuggerProperties); if ASource.DebuggerClass <> nil then
if ASource.DebuggerClass <> nil then FDebuggerProperties := ASource.DebuggerClass.CreateProperties;
FDebuggerProperties := ASource.DebuggerClass.CreateProperties; if ACopyPropValues and (ASource.FDebuggerProperties <> nil) then
if ACopyPropValues and (ASource.FDebuggerProperties <> nil) then FDebuggerProperties.Assign(ASource.FDebuggerProperties);
FDebuggerProperties.Assign(ASource.FDebuggerProperties);
end;
FUID := ''; FUID := '';
InitUID; InitUID;
@ -347,7 +342,7 @@ procedure TDebuggerPropertiesConfig.ChangeDebuggerClass(
var var
p: TDebuggerProperties; p: TDebuggerProperties;
begin begin
assert(IsLoaded and not IsDeleted, 'TDebuggerPropertiesConfig.ChangeDebuggerClass: IsLoaded'); assert(IsLoaded, 'TDebuggerPropertiesConfig.ChangeDebuggerClass: IsLoaded');
FDebuggerClass := ADebuggerClass; FDebuggerClass := ADebuggerClass;
FConfigClass := ADebuggerClass.ClassName; FConfigClass := ADebuggerClass.ClassName;
p := FDebuggerProperties; p := FDebuggerProperties;
@ -357,22 +352,11 @@ begin
p.Free; p.Free;
end; end;
procedure TDebuggerPropertiesConfig.MarkAsDeleted;
begin
FreeAndNil(FDebuggerProperties);
FFLags := FFLags + [dpcDeleted];
end;
function TDebuggerPropertiesConfig.IsLoaded: Boolean; function TDebuggerPropertiesConfig.IsLoaded: Boolean;
begin begin
Result := dpcLoaded in FFLags; // (FDebuggerClass <> nil) and (FDebuggerProperties <> nil); Result := dpcLoaded in FFLags; // (FDebuggerClass <> nil) and (FDebuggerProperties <> nil);
end; end;
function TDebuggerPropertiesConfig.IsDeleted: Boolean;
begin
Result := dpcDeleted in FFLags; // (FDebuggerClass <> nil) and (FDebuggerProperties = nil);
end;
function TDebuggerPropertiesConfig.DebugText: String; function TDebuggerPropertiesConfig.DebugText: String;
begin begin
if Self = nil then if Self = nil then
@ -491,6 +475,12 @@ begin
FCurrentDebuggerPropertiesConfig := AValue; FCurrentDebuggerPropertiesConfig := AValue;
end; end;
constructor TDebuggerPropertiesConfigList.Create;
begin
inherited Create;
OwnsObjects := True;
end;
procedure TDebuggerPropertiesConfigList.LoadFromXml(AXMLCfg: TRttiXMLConfig; procedure TDebuggerPropertiesConfigList.LoadFromXml(AXMLCfg: TRttiXMLConfig;
APath: String); APath: String);
var var
@ -506,7 +496,7 @@ begin
HasActiveDebuggerEntry := False; HasActiveDebuggerEntry := False;
ClearAll; Clear;
FCurrentDebuggerPropertiesConfig := nil; FCurrentDebuggerPropertiesConfig := nil;
ConfCount := AXMLCfg.GetListItemCount(APath, 'Config', False); ConfCount := AXMLCfg.GetListItemCount(APath, 'Config', False);
@ -602,8 +592,6 @@ begin
Idx := 1; Idx := 1;
for i := 0 to Count - 1 do begin for i := 0 to Count - 1 do begin
Entry := Opt[i]; Entry := Opt[i];
if Entry.IsDeleted then
Continue;
Entry.Active := Entry = FCurrentDebuggerPropertiesConfig; Entry.Active := Entry = FCurrentDebuggerPropertiesConfig;
Entry.SaveToXml(AXMLCfg, APath + XML_PATH_DEBUGGER_CONF, Idx); Entry.SaveToXml(AXMLCfg, APath + XML_PATH_DEBUGGER_CONF, Idx);
@ -614,25 +602,6 @@ begin
AXMLCfg.SetValue(APath+'Version', 1); AXMLCfg.SetValue(APath+'Version', 1);
end; end;
procedure TDebuggerPropertiesConfigList.ClearAll;
var
i: Integer;
begin
for i := 0 to Count - 1 do
Objects[i].Free;
Clear;
end;
function TDebuggerPropertiesConfigList.CountWithoutDeleted: Integer;
var
i: Integer;
begin
Result := 0;
for i := 0 to Count - 1 do
if not Opt[i].IsDeleted then
inc(Result);
end;
function TDebuggerPropertiesConfigList.EntryByName(AConfName, AConfClass: String function TDebuggerPropertiesConfigList.EntryByName(AConfName, AConfClass: String
): TDebuggerPropertiesConfig; ): TDebuggerPropertiesConfig;
var var
@ -643,7 +612,7 @@ begin
i := Count - 1; i := Count - 1;
while i >= 0 do begin while i >= 0 do begin
dpCfg := Opt[i]; dpCfg := Opt[i];
if (not dpCfg.IsDeleted) and dpCfg.IsLoaded if dpCfg.IsLoaded
and (dpCfg.ConfigName = AConfName) and (dpCfg.ConfigName = AConfName)
and (dpCfg.ConfigClass = AConfClass) then and (dpCfg.ConfigClass = AConfClass) then
Break; Break;
@ -700,9 +669,7 @@ destructor TDebuggerOptions.Destroy;
begin begin
inherited Destroy; inherited Destroy;
BackendConverterConfig.Free; BackendConverterConfig.Free;
FDebuggerConfigList.Free;
FDebuggerConfigList.ClearAll;
FreeAndNil(FDebuggerConfigList);
FXMLCfg.Free; FXMLCfg.Free;
end; end;

View File

@ -530,7 +530,7 @@ begin
writeln(opts.DebuggerPropertiesConfigList.Count); writeln(opts.DebuggerPropertiesConfigList.Count);
for i := 0 to opts.DebuggerPropertiesConfigList.Count - 1 do for i := 0 to opts.DebuggerPropertiesConfigList.Count - 1 do
with opts.DebuggerPropertiesConfigList.Opt[i] do with opts.DebuggerPropertiesConfigList.Opt[i] do
WriteLn(' # ', ConfigName, 'C=', ConfigClass, ' , A=', Active, ' , D=', IsDeleted, ' , L=',IsLoaded); WriteLn(' # ', ConfigName, 'C=', ConfigClass, ' , A=', Active, ' , L=',IsLoaded);
end; end;
procedure TTestXmlOpts.TearDown; procedure TTestXmlOpts.TearDown;

View File

@ -2881,7 +2881,6 @@ begin
FreeThenNil(FDefineTemplates); FreeThenNil(FDefineTemplates);
FreeThenNil(FHistoryLists); FreeThenNil(FHistoryLists);
{$IFnDEF LCLNOGUI} {$IFnDEF LCLNOGUI}
FDebuggerProperties.ClearAll;
FreeAndNil(FDebuggerProperties); FreeAndNil(FDebuggerProperties);
FreeAndNil(FBackendConverterConfig); FreeAndNil(FBackendConverterConfig);
{$EndIf} {$EndIf}