View Issue Details

IDProjectCategoryView StatusLast Update
0032077LazarusLCLpublic2017-06-29 16:33
ReporterTony Whyman Assigned Towp  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformX86_64OSLinux Mint 
Product Version1.8RC2 
Summary0032077: Access Violation in TDBRadioGroup.UpdateRadioButtonStates
DescriptionThis is a minor programming issue. At line 146 there is an unprotected reference to Datalink.Field.AsString in TDBRadioGroup.UpdateRadioButtonStates. i.e.

"else if (not DataLink.CanModify) and (DataLink.Field.AsString <> NewValue) then "

If for some reason the Field is empty then an Access Violation occurs.
Steps To ReproduceAdd a TDBRadioGroup to a form and forget to assign a DataField to it.
Additional InformationSuggested patch attached
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0031993 closedwp (Patch)RadioItems from TDBRadioGroup is changeable also by TDataSet.ReadOnly=true 

Activities

Tony Whyman

2017-06-29 12:45

reporter  

dbradiogroup.patch (719 bytes)   
Index: lcl/include/dbradiogroup.inc
===================================================================
--- lcl/include/dbradiogroup.inc	(revision 55412)
+++ lcl/include/dbradiogroup.inc	(working copy)
@@ -143,7 +143,7 @@
   // Workaround for TDBRadiogroup not having a ReadOnly property (i.e. ItemIndex
   // can be changed even if Dataset is ReadOnly)
   // See isse https://bugs.freepascal.org/view.php?id=31993
-  else if (not DataLink.CanModify) and (DataLink.Field.AsString <> NewValue) then
+  else if (not DataLink.CanModify) and ((DataLink.Field = nil) or (DataLink.Field.AsString <> NewValue)) then
   begin
     FValue := ''; // Otherwise, SetValue in next line would exit immediately
     Value:= OldValue;
dbradiogroup.patch (719 bytes)   

wp

2017-06-29 16:11

developer   ~0101384

Fixed in r55413. Thanks for reporting. Please test and close if OK.

Issue History

Date Modified Username Field Change
2017-06-29 12:45 Tony Whyman New Issue
2017-06-29 12:45 Tony Whyman File Added: dbradiogroup.patch
2017-06-29 15:52 wp Assigned To => wp
2017-06-29 15:52 wp Status new => assigned
2017-06-29 15:52 wp Relationship added related to 0031993
2017-06-29 16:11 wp Note Added: 0101384
2017-06-29 16:33 wp LazTarget => -
2017-06-29 16:33 wp Status assigned => resolved
2017-06-29 16:33 wp Resolution open => fixed