mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 15:09:46 +02:00
implemented TCustomForm.Release
git-svn-id: trunk@5819 -
This commit is contained in:
parent
b188fee924
commit
0ae50847ff
@ -792,7 +792,9 @@ type
|
||||
AppWaiting,
|
||||
AppIdleEndSent,
|
||||
AppHandlingException,
|
||||
AppNoExceptionMessages
|
||||
AppNoExceptionMessages,
|
||||
AppDestroying,
|
||||
AppDoNotReleaseComponents
|
||||
);
|
||||
TApplicationFlags = set of TApplicationFlag;
|
||||
|
||||
@ -832,6 +834,7 @@ type
|
||||
FOnIdleEnd: TNotifyEvent;
|
||||
FOnShowHint: TShowHintEvent;
|
||||
FOnUserInput: TOnUserInputEvent;
|
||||
FReleaseComponents: TList;
|
||||
FShowHint: Boolean;
|
||||
procedure DoOnIdleEnd;
|
||||
function GetCurrentHelpFile: string;
|
||||
@ -870,12 +873,14 @@ type
|
||||
procedure UpdateVisible;
|
||||
procedure DoIdleActions;
|
||||
procedure MenuPopupHandler(Sender: TObject);
|
||||
procedure DoFreeReleaseComponents;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure ControlDestroyed(AControl: TControl);
|
||||
Procedure BringToFront;
|
||||
procedure CreateForm(InstanceClass: TComponentClass; var Reference);
|
||||
procedure ReleaseComponent(AComponent: TComponent);
|
||||
function ExecuteAction(ExeAction: TBasicAction): Boolean; override;
|
||||
function UpdateAction(TheAction: TBasicAction): Boolean; override;
|
||||
function HandleAllocated: boolean;
|
||||
|
@ -101,6 +101,8 @@ destructor TApplication.Destroy;
|
||||
var
|
||||
HandlerType: TApplicationHandlerType;
|
||||
begin
|
||||
Include(FFlags,AppDestroying);
|
||||
DoFreeReleaseComponents;
|
||||
if OnMenuPopupHandler=@MenuPopupHandler then
|
||||
OnMenuPopupHandler:=nil;
|
||||
|
||||
@ -117,6 +119,9 @@ begin
|
||||
do
|
||||
FreeThenNil(FApplicationHandlers[HandlerType]);
|
||||
inherited Destroy;
|
||||
|
||||
Include(FFlags,AppDoNotReleaseComponents);
|
||||
DoFreeReleaseComponents;
|
||||
|
||||
// restore exception handling
|
||||
CaptureExceptions:=false;
|
||||
@ -284,6 +289,7 @@ procedure TApplication.Idle;
|
||||
var
|
||||
Done: Boolean;
|
||||
begin
|
||||
DoFreeReleaseComponents;
|
||||
MouseIdle(GetControlAtMouse);
|
||||
|
||||
Done := True;
|
||||
@ -685,6 +691,24 @@ begin
|
||||
HideHint;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TApplication.DoFreeReleaseComponents
|
||||
|
||||
Free all components that were queued for freeing (ReleaseComponent)
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TApplication.DoFreeReleaseComponents;
|
||||
var
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
if FReleaseComponents=nil then exit;
|
||||
while FReleaseComponents.Count>0 do begin
|
||||
AComponent:=TComponent(FReleaseComponents[0]);
|
||||
FReleaseComponents.Delete(0);
|
||||
AComponent.Free;
|
||||
end;
|
||||
FreeThenNil(FReleaseComponents);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TApplication.IconChanged
|
||||
------------------------------------------------------------------------------}
|
||||
@ -887,8 +911,7 @@ procedure TApplication.Run;
|
||||
end;
|
||||
|
||||
begin
|
||||
if FMainForm <> nil
|
||||
then FMainForm.Show;
|
||||
if FMainForm <> nil then FMainForm.Show;
|
||||
repeat
|
||||
if CaptureExceptions then begin
|
||||
// run with try..except
|
||||
@ -1187,6 +1210,16 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TApplication.ReleaseComponent(AComponent: TComponent);
|
||||
begin
|
||||
if AppDoNotReleaseComponents in FFlags then
|
||||
raise Exception.Create('TApplication.ReleaseComponent already shut down');
|
||||
if FReleaseComponents=nil then
|
||||
FReleaseComponents:=TList.Create;
|
||||
if FReleaseComponents.IndexOf(AComponent)<0 then
|
||||
FReleaseComponents.Add(AComponent);
|
||||
end;
|
||||
|
||||
function TApplication.ExecuteAction(ExeAction: TBasicAction): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
@ -1214,6 +1247,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.86 2004/08/18 14:24:55 mattias
|
||||
implemented TCustomForm.Release
|
||||
|
||||
Revision 1.85 2004/08/13 10:20:19 mattias
|
||||
fixed codetools ConstSet, implemented notifying TApplication whenmenu popups
|
||||
|
||||
|
@ -70,7 +70,7 @@ begin
|
||||
end;
|
||||
case CloseAction of
|
||||
caNone: ModalResult := 0;
|
||||
//caFree: Release;
|
||||
caFree: Release;
|
||||
end;
|
||||
except
|
||||
ModalResult := 0;
|
||||
@ -1212,7 +1212,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomForm.Release;
|
||||
begin
|
||||
Free;
|
||||
if Application<>nil then
|
||||
Application.ReleaseComponent(Self)
|
||||
else
|
||||
Free;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1719,6 +1722,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.151 2004/08/18 14:24:55 mattias
|
||||
implemented TCustomForm.Release
|
||||
|
||||
Revision 1.150 2004/08/16 22:09:18 mattias
|
||||
started TCustomDockForm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user