RxFPC:fix AV on dinamicaly creat and remove components

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5270 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-10-19 11:59:59 +00:00
parent cacfb22337
commit 28e7cd7c4b
2 changed files with 30 additions and 1 deletions

View File

@ -471,6 +471,7 @@ msgid "Optimize column width"
msgstr "Оптимізувати ширину колонок" msgstr "Оптимізувати ширину колонок"
#: rxdconst.srxdbgridselapplycaption #: rxdconst.srxdbgridselapplycaption
msgctxt "rxdconst.srxdbgridselapplycaption"
msgid "Apply" msgid "Apply"
msgstr "Застосувати" msgstr "Застосувати"

View File

@ -59,6 +59,8 @@ type
private private
FMenu:TPopupMenu; FMenu:TPopupMenu;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public public
constructor CreateButton(AOwner:TRxMDITasks; AForm:TForm); constructor CreateButton(AOwner:TRxMDITasks; AForm:TForm);
procedure Click; override; // make Click public procedure Click; override; // make Click public
@ -130,6 +132,7 @@ type
procedure SetTaskPanel(AValue: TRxMDITasks); procedure SetTaskPanel(AValue: TRxMDITasks);
function MDIButtonByForm(AForm:TForm):TRxMDIButton; function MDIButtonByForm(AForm:TForm):TRxMDIButton;
procedure HideCurrentWindow; procedure HideCurrentWindow;
procedure ScreenEventRemoveForm(Sender: TObject; Form: TCustomForm);
protected protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Loaded; override; procedure Loaded; override;
@ -218,7 +221,7 @@ begin
begin begin
FMDIPanel:=nil; FMDIPanel:=nil;
OnClick:=nil; OnClick:=nil;
end; end
end; end;
procedure TRxMDICloseButton.CreateInternalLabel; procedure TRxMDICloseButton.CreateInternalLabel;
@ -320,6 +323,20 @@ begin
end; end;
end; end;
procedure TRxMDIPanel.ScreenEventRemoveForm(Sender: TObject; Form: TCustomForm);
var
i: Integer;
begin
if Assigned(FTaskPanel) then
begin
for i:=0 to FTaskPanel.ComponentCount-1 do
begin;
if (FTaskPanel.Components[i] is TRxMDIButton) and (TRxMDIButton(FTaskPanel.Components[i]).NavForm = Form) then
TRxMDIButton(FTaskPanel.Components[i]).FActiveControl:=nil;
end;
end;
end;
procedure TRxMDIPanel.Notification(AComponent: TComponent; Operation: TOperation procedure TRxMDIPanel.Notification(AComponent: TComponent; Operation: TOperation
); );
begin begin
@ -343,10 +360,13 @@ begin
Caption:=''; Caption:='';
Align:=alClient; Align:=alClient;
BevelOuter:=bvLowered; BevelOuter:=bvLowered;
Screen.AddHandlerRemoveForm(@ScreenEventRemoveForm);
end; end;
destructor TRxMDIPanel.Destroy; destructor TRxMDIPanel.Destroy;
begin begin
Screen.RemoveHandlerRemoveForm(@ScreenEventRemoveForm);
inherited Destroy; inherited Destroy;
end; end;
@ -736,6 +756,14 @@ begin
Application.ReleaseComponent(Self); Application.ReleaseComponent(Self);
end; end;
procedure TRxMDIButton.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (AComponent = FActiveControl) and (Operation = opRemove) then
FActiveControl := nil
end;
constructor TRxMDIButton.CreateButton(AOwner: TRxMDITasks; AForm: TForm); constructor TRxMDIButton.CreateButton(AOwner: TRxMDITasks; AForm: TForm);
begin begin
inherited Create(AOwner); inherited Create(AOwner);