View Issue Details

IDProjectCategoryView StatusLast Update
0021735LazarusLCLpublic2012-04-16 07:38
ReporterDavid JenkinsAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version0.9.30.5 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0021735: FActiveDefaultControl points at destroyed control
DescriptionFActiveDefaultControl management.

For buttons the SetActiveDefaultControl is only nil'd with a call to WMKillFocus. Carbon does not pass a KillFocus event back when control is destroyed. So we were seeing a case where FActiveDefaultControl was pointing to a destroyed TButton.

Suggested fix is connecting the Form and FActiveDefaultControl with a FreeNotification to make sure that FActiveDefaultControl is set to nil if control it is pointing at is destroyed.

Patch against 36681 is attached
TagsNo tags attached.
Fixed in Revision36806
LazTarget-
WidgetsetCarbon
Attached Files
  • customform.inc.patch (854 bytes)
    --- /Users/djenkins/laz-changes/14588/customform.inc	2012-04-11 11:42:25.000000000 
    +++ /Users/djenkins/laz-changes/14588/customform.inc.ss	2012-04-11 11:43:14.000000000 
    @@ -251,6 +251,8 @@
             end;
             if AComponent = FDefaultControl then
               FDefaultControl := nil;
    +        if AComponent = FActiveDefaultControl then
    +          FActiveDefaultControl := nil;
             if AComponent = FCancelControl then
               FCancelControl := nil;
             if AComponent = FLastFocusedControl then
    @@ -1826,6 +1828,7 @@
       if AControl = FActiveDefaultControl then exit;
       lPrevControl := FActiveDefaultControl;
       FActiveDefaultControl := AControl;
    +  if Assigned(FActiveDefaultControl) then FreeNotification(FActiveDefaultControl);
     
       // notify previous active default control that he has lost "default-ness"
       if lPrevControl <> nil then
    
    customform.inc.patch (854 bytes)

Activities

2012-04-13 18:50

 

customform.inc.patch (854 bytes)
--- /Users/djenkins/laz-changes/14588/customform.inc	2012-04-11 11:42:25.000000000 
+++ /Users/djenkins/laz-changes/14588/customform.inc.ss	2012-04-11 11:43:14.000000000 
@@ -251,6 +251,8 @@
         end;
         if AComponent = FDefaultControl then
           FDefaultControl := nil;
+        if AComponent = FActiveDefaultControl then
+          FActiveDefaultControl := nil;
         if AComponent = FCancelControl then
           FCancelControl := nil;
         if AComponent = FLastFocusedControl then
@@ -1826,6 +1828,7 @@
   if AControl = FActiveDefaultControl then exit;
   lPrevControl := FActiveDefaultControl;
   FActiveDefaultControl := AControl;
+  if Assigned(FActiveDefaultControl) then FreeNotification(FActiveDefaultControl);
 
   // notify previous active default control that he has lost "default-ness"
   if lPrevControl <> nil then
customform.inc.patch (854 bytes)

Luiz Americo

2012-04-13 20:05

developer   ~0058559

> Carbon does not pass a KillFocus event back when control is destroyed.

Maybe sending a KILLFOCUS message while widget is about to be destroyied can be a better fix. Makes consistent with other widgetsets and other controls that catch KillFocus can benefit. Not sure if is possible under carbon

Paul Ishenin

2012-04-16 07:38

manager   ~0058641

Please test and close if ok.

Issue History

Date Modified Username Field Change
2012-04-13 18:50 David Jenkins New Issue
2012-04-13 18:50 David Jenkins File Added: customform.inc.patch
2012-04-13 18:50 David Jenkins Widgetset => Carbon
2012-04-13 20:05 Luiz Americo Note Added: 0058559
2012-04-16 07:38 Paul Ishenin Fixed in Revision => 36806
2012-04-16 07:38 Paul Ishenin LazTarget => -
2012-04-16 07:38 Paul Ishenin Status new => resolved
2012-04-16 07:38 Paul Ishenin Fixed in Version => 1.1 (SVN)
2012-04-16 07:38 Paul Ishenin Resolution open => fixed
2012-04-16 07:38 Paul Ishenin Assigned To => Paul Ishenin
2012-04-16 07:38 Paul Ishenin Note Added: 0058641