lcl: clear FActiveDefaultControl on that control destruction (based on patch of David Jenkins, issue #0021735)

git-svn-id: trunk@36806 -
This commit is contained in:
paul 2012-04-16 05:38:16 +00:00
parent 62cc1885af
commit a34725fc50

View File

@ -262,6 +262,8 @@ begin
{$ENDIF}
FActiveControl := nil;
end;
if AComponent = FActiveDefaultControl then
FActiveDefaultControl := nil;
if AComponent = FDefaultControl then
FDefaultControl := nil;
if AComponent = FCancelControl then
@ -269,7 +271,7 @@ begin
if AComponent = FLastFocusedControl then
FLastFocusedControl := nil;
// then do stuff which can trigger things
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
if Assigned(FActionLists) and (AComponent is TCustomActionList) then
DoRemoveActionList(TCustomActionList(AComponent))
else
if AComponent = Menu then
@ -1840,11 +1842,14 @@ begin
lPrevControl := FActiveDefaultControl;
FActiveDefaultControl := AControl;
if Assigned(FActiveDefaultControl) then
FActiveDefaultControl.FreeNotification(Self);
// notify previous active default control that he has lost "default-ness"
if lPrevControl <> nil then
if Assigned(lPrevControl) then
lPrevControl.ActiveDefaultControlChanged(AControl);
// notify default control that it may become/lost active default again
if (FDefaultControl <> nil) and (FDefaultControl <> lPrevControl) then
if Assigned(FDefaultControl) and (FDefaultControl <> lPrevControl) then
FDefaultControl.ActiveDefaultControlChanged(AControl);
end;
@ -1927,9 +1932,9 @@ end;
procedure TCustomForm.SetLastFocusedControl(AControl: TWinControl);
begin
if FLastFocusedControl=AControl then exit;
FLastFocusedControl:=AControl;
if FLastFocusedControl<>nil then
if FLastFocusedControl = AControl then exit;
FLastFocusedControl := AControl;
if Assigned(FLastFocusedControl) then
FLastFocusedControl.FreeNotification(Self);
end;
@ -2560,10 +2565,8 @@ end;
procedure TCustomForm.DestroyWnd;
begin
if FMenu <> nil then
begin
if Assigned(FMenu) then
FMenu.DestroyHandle;
end;
inherited DestroyWnd;
end;