IDE: Assign also the handler list in BuildModes. Prevents a crash when cancelling project options. Issue #36782.

git-svn-id: trunk@63009 -
This commit is contained in:
juha 2020-04-17 18:39:38 +00:00
parent ed5d93546e
commit cbaeca66f0
2 changed files with 29 additions and 8 deletions

View File

@ -47,6 +47,8 @@ type
function Count: integer;
function NextDownIndex(var Index: integer): boolean;
function IndexOf(const AMethod: TMethod): integer;
procedure Assign(Source: TMethodList);
procedure Clear;
procedure Delete(Index: integer);
procedure Remove(const AMethod: TMethod);
procedure Add(const AMethod: TMethod);
@ -177,7 +179,7 @@ end;
destructor TMethodList.Destroy;
begin
ReAllocMem(FItems,0);
Clear;
inherited Destroy;
end;
@ -218,6 +220,20 @@ begin
Result:=-1;
end;
procedure TMethodList.Assign(Source: TMethodList);
var
i: Integer;
begin
Clear;
for i := 0 to Source.Count-1 do
Add(Source.Items[i]);
end;
procedure TMethodList.Clear;
begin
ReAllocMem(FItems,0);
end;
procedure TMethodList.Delete(Index: integer);
begin
dec(FCount);

View File

@ -611,7 +611,7 @@ type
fSavedChangeStamp: int64;
fItems: TFPList;
FLazProject: TProject;
fOnChanged: TMethodList;
fChangedHandlers: TMethodList;
// Variables used by LoadFromXMLConfig and SaveToXMLConfig
FXMLConfig: TXMLConfig;
FGlobalMatrixOptions: TBuildMatrixOptions;
@ -671,6 +671,8 @@ type
property SharedMatrixOptions: TBuildMatrixOptions read FSharedMatrixOptions;
property SessionMatrixOptions: TBuildMatrixOptions read FSessionMatrixOptions;
property ManyBuildModes: TStringList read FManyBuildModes;
property ChangedHandlers: TMethodList read fChangedHandlers;
end;
{ TProjectIDEOptions }
@ -7000,7 +7002,7 @@ end;
constructor TProjectBuildModes.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fOnChanged:=TMethodList.Create;
fChangedHandlers:=TMethodList.Create;
fItems:=TFPList.Create;
FChangeStamp:=CTInvalidChangeStamp;
fSavedChangeStamp:=FChangeStamp;
@ -7013,7 +7015,7 @@ end;
destructor TProjectBuildModes.Destroy;
begin
FreeAndNil(fOnChanged);
FreeAndNil(fChangedHandlers);
Clear;
FreeAndNil(FManyBuildModes);
FreeAndNil(FSharedMatrixOptions);
@ -7024,9 +7026,11 @@ end;
procedure TProjectBuildModes.Clear;
begin
while Count>0 do Delete(Count-1);
while Count>0 do
Delete(Count-1);
SharedMatrixOptions.Clear;
SessionMatrixOptions.Clear;
//fChangedHandlers.Clear;
end;
function TProjectBuildModes.IsEqual(OtherModes: TProjectBuildModes): boolean;
@ -7062,6 +7066,7 @@ begin
SharedMatrixOptions.Assign(OtherModes.SharedMatrixOptions);
SessionMatrixOptions.Assign(OtherModes.SessionMatrixOptions);
ManyBuildModes.Assign(OtherModes.ManyBuildModes);
ChangedHandlers.Assign(OtherModes.ChangedHandlers);
if WithModified then
Modified:=OtherModes.Modified;
FAssigning:=False;
@ -7129,17 +7134,17 @@ end;
procedure TProjectBuildModes.IncreaseChangeStamp;
begin
CTIncreaseChangeStamp(FChangeStamp);
if fOnChanged<>nil then fOnChanged.CallNotifyEvents(Self);
if fChangedHandlers<>nil then fChangedHandlers.CallNotifyEvents(Self);
end;
procedure TProjectBuildModes.AddOnChangedHandler(const Handler: TNotifyEvent);
begin
fOnChanged.Add(TMethod(Handler));
fChangedHandlers.Add(TMethod(Handler));
end;
procedure TProjectBuildModes.RemoveOnChangedHandler(const Handler: TNotifyEvent);
begin
fOnChanged.Remove(TMethod(Handler));
fChangedHandlers.Remove(TMethod(Handler));
end;
function TProjectBuildModes.IsModified(InSession: boolean): boolean;