View Issue Details

IDProjectCategoryView StatusLast Update
0013950LazarusLCLpublic2009-10-23 00:40
ReporterLuca Olivetti Assigned ToJesus Reyes  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.27 (SVN) 
Target Version0.9.28Fixed in Version0.9.27 (SVN) 
Summary0013950: TDbLookupCombo causes segfault if associated dataset is closed and reopened
DescriptionThe segfault is in method TDbLookup.ListFieldValue that is called right after FListField has been assigned to nil.
The attached patch fixes it, however I think it's just a hack and what's wrong is the underlying chain of events (I think FListField should be updated only if the dataset associated to ListSource changes, regardless of the dataset associated to DataSource, however fixing it right is out of my reach).
Steps To ReproduceRun the attached program and click the CrashMe button.
TagsNo tags attached.
Fixed in Revision20683
LazTarget0.9.28
Widgetset
Attached Files

Activities

2009-06-10 15:07

 

lookupbug.zip (4,351 bytes)

2009-06-10 15:08

 

dblookup.patch (493 bytes)   
--- C:/DOCUME~1/luca/CONFIG~1/Temp/dblookup.in-revBASE.svn001.tmp.inc	mi� jun 10 15:05:57 2009
+++ C:/lazsvn/lcl/include/dblookup.inc	mi� jun 10 14:37:58 2009
@@ -249,7 +249,7 @@
   TmpActive: Boolean;
 begin
   Result := '';
-  if not ((Assigned(FControlLink) and FControlLink.Active)) then
+  if not ((Assigned(FControlLink) and Assigned(FListField) and FControlLink.Active)) then
     Exit;
   Key := FControlLink.DataSet.FieldValues[FDataFieldNames];
   if FHasLookupField then
dblookup.patch (493 bytes)   

Vincent Snijders

2009-06-10 15:09

manager   ~0028446

Target 0.9.28 to review the patch.

Target should be set to 1.0 if the patch cannot be used.

Daniel Simões de Almeida

2009-06-19 01:53

reporter   ~0028618

I note the same problem...
Is possible to reproduce the error using project on folder:
\lazarus\examples\database\dblookup

Just add a buttom on Form and the code to Onclick
procedure TForm1.Button1Click(Sender: TObject);
begin
   Dbf2.Active:= not Dbf2.Active;
end;

After Close, and re-open a segfault exception is raised.

I added another way to patch this file

2009-06-19 01:54

 

dblookup.inc.patch (489 bytes)   
Index: dblookup.inc
===================================================================
--- dblookup.inc	(revis�o 20665)
+++ dblookup.inc	(c�pia de trabalho)
@@ -271,7 +271,7 @@
   else
     FListLink.DataSet.Active := True;
   try
-    if FListLink.DataSet.Locate(FKeyFieldNames,
+    if Assigned( FListField ) and FListLink.DataSet.Locate(FKeyFieldNames,
       FControlLink.DataSet.FieldValues[FDataFieldNames], []) then
       Result := FListField.AsString
     else Result:= '';
dblookup.inc.patch (489 bytes)   

Jesus Reyes

2009-06-20 21:43

developer   ~0028649

Thanks Lucas and Daniel, I used the Daniel's patch to fix it.

About the concern if it's the right way to fix it, I will to let Leslie Kaye, the autor of dblookup controls, the decision if it needs to be redesigned.

Issue History

Date Modified Username Field Change
2009-06-10 15:07 Luca Olivetti New Issue
2009-06-10 15:07 Luca Olivetti File Added: lookupbug.zip
2009-06-10 15:08 Luca Olivetti File Added: dblookup.patch
2009-06-10 15:09 Vincent Snijders LazTarget => 0.9.28
2009-06-10 15:09 Vincent Snijders Note Added: 0028446
2009-06-10 15:09 Vincent Snijders Assigned To => Jesus Reyes
2009-06-10 15:09 Vincent Snijders Status new => assigned
2009-06-10 15:09 Vincent Snijders Target Version => 0.9.28
2009-06-19 01:53 Daniel Simões de Almeida Note Added: 0028618
2009-06-19 01:54 Daniel Simões de Almeida File Added: dblookup.inc.patch
2009-06-20 21:43 Jesus Reyes Fixed in Revision => 20683
2009-06-20 21:43 Jesus Reyes Status assigned => resolved
2009-06-20 21:43 Jesus Reyes Fixed in Version => 0.9.27 (SVN)
2009-06-20 21:43 Jesus Reyes Resolution open => fixed
2009-06-20 21:43 Jesus Reyes Note Added: 0028649
2009-10-23 00:40 Marc Weustink Status resolved => closed