mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 14:18:17 +02:00
LCL: Application.ReleaseComponent: try to keep the order, bug #16859
git-svn-id: trunk@26484 -
This commit is contained in:
parent
7ceff41935
commit
a09d8339a6
@ -1171,8 +1171,8 @@ type
|
||||
FApplicationHandlers: array[TApplicationHandlerType] of TMethodList;
|
||||
FApplicationType: TApplicationType;
|
||||
FCaptureExceptions: boolean;
|
||||
FComponentsToRelease: TAvgLvlTree;
|
||||
FComponentsReleasing: TAvgLvlTree;
|
||||
FComponentsToRelease: TFPList;
|
||||
FComponentsReleasing: TFPList;
|
||||
FCreatingForm: TForm;// currently created form (CreateForm), candidate for MainForm
|
||||
FFindGlobalComponentEnabled: boolean;
|
||||
FFlags: TApplicationFlags;
|
||||
|
@ -2185,7 +2185,6 @@ end;
|
||||
procedure TApplication.ReleaseComponents;
|
||||
var
|
||||
Component: TComponent;
|
||||
Node: TAvgLvlTreeNode;
|
||||
begin
|
||||
if FComponentsReleasing<>nil then exit; // currently releasing
|
||||
if (FComponentsToRelease<>nil) then begin
|
||||
@ -2203,14 +2202,14 @@ begin
|
||||
try
|
||||
while (FComponentsReleasing<>nil) and (FComponentsReleasing.Count>0) do
|
||||
begin
|
||||
Node:=FComponentsReleasing.FindLowest;
|
||||
Component:=TComponent(Node.Data);
|
||||
FComponentsReleasing.Delete(Node);
|
||||
Component:=TComponent(FComponentsReleasing[0]);
|
||||
FComponentsReleasing.Delete(0);
|
||||
if (Component is TLCLComponent)
|
||||
and (TLCLComponent(Component).LCLRefCount>0) then begin
|
||||
// add again to FComponentsToRelease
|
||||
ReleaseComponent(Component);
|
||||
end else begin
|
||||
// this might free some more components from FComponentsReleasing
|
||||
Component.Free;
|
||||
end;
|
||||
end;
|
||||
@ -2218,9 +2217,8 @@ begin
|
||||
// add remaining to FComponentsToRelease
|
||||
while (FComponentsReleasing<>nil) and (FComponentsReleasing.Count>0) do
|
||||
begin
|
||||
Node:=FComponentsReleasing.FindLowest;
|
||||
Component:=TComponent(Node.Data);
|
||||
FComponentsReleasing.Delete(Node);
|
||||
Component:=TComponent(FComponentsReleasing[0]);
|
||||
FComponentsReleasing.Delete(0);
|
||||
ReleaseComponent(Component);
|
||||
end;
|
||||
FreeAndNil(FComponentsReleasing);
|
||||
@ -2242,8 +2240,8 @@ begin
|
||||
// => add to the FComponentsToRelease
|
||||
IsFirstItem:=FComponentsToRelease=nil;
|
||||
if IsFirstItem then
|
||||
FComponentsToRelease:=TAvgLvlTree.Create(@ComparePointers)
|
||||
else if FComponentsToRelease.Find(AComponent)<>nil then
|
||||
FComponentsToRelease:=TFPList.Create
|
||||
else if FComponentsToRelease.IndexOf(AComponent)>=0 then
|
||||
exit;
|
||||
FComponentsToRelease.Add(AComponent);
|
||||
AComponent.FreeNotification(Self);
|
||||
|
Loading…
Reference in New Issue
Block a user