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