TForm.DefaultControl is not cleared on removal of indirect child control
Original Reporter info from Mantis: Dmitry24
-
Reporter name: Dmitry
Original Reporter info from Mantis: Dmitry24
- Reporter name: Dmitry
Description:
If an active default form control is placed on a layer (Form - Layer - Control) and Layer is removed then the Form is not notified about about removal of its active control. Thus TFrom.FActiveDefaultControl or TFrom.FDefaultControl (and propbably other values) are not cleared properly and later they can be wrongly accessed causing exceptions. Simple app is listed to reproduce the bug. For me it always causes SIGSEGV exception (Windows platform).
Steps to reproduce:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormActivate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormActivate(Sender: TObject);
var
T: TPanel;
B: TButton;
begin
T:= TPanel.Create(Self);
T.Parent:= Self;
B:= TButton.Create(Self);
B.Parent:= T;
B.Default:= True;
FreeAndNil(T);
B:= TButton.Create(Self);
B.Parent:= Self;
B.Default:= True; //At this moment the removed button is accessed for notification!!
end;
end.
Mantis conversion info:
- Mantis ID: 38223
- Version: 2.0.10