[fpc-devel] Recent changes to TField.SetData

LacaK lacak at zoznam.sk
Tue Apr 5 10:01:21 CEST 2011


michael.vancanneyt at wisa.be  wrote / napĂ­sal(a):
>
>
> On Tue, 5 Apr 2011, LacaK wrote:
>
>>
>>>
>>>
>>> --or--
>>> introduce any new method (ValidateFieldData ? ;-))) and let tdatsset 
>>> descendants use it:
>>> {$IFDEF FPC}
>>> ValidateFieldData(Field: TField; Buffer: Pointer);
>>> {$ENDIF}
>>>
>>> --or--
>>> some smarter solution ?
>>>
>> The whole code, which is repeated (and can be put in one place) is:
>>
>> if not (State in [dsEdit, dsInsert, dsFilter, dsCalcFields]) then
>> begin
>>   DatabaseErrorFmt(SNotEditing,[Name],self);
>>   exit;
>> end;
>> if (Field.FieldNo>0) and not (State in [dsSetKey, dsFilter]) then
>> begin
>>   if Read     
>> OnlythenDatabaseErrorFmtSReadOnlyField,[Field.DisplayName],
>> Self);
>>   Field.Validate(Buffer);
>> end;
>
> You are right in your dislike.
>
> I will create a 'BeforeSetFieldData' in TDataset and put the code in 
> there,
> and the same for 'AfterSetFieldData' with the OnChange code.
>
OK,
Then please do not forget commit necessary changes also in other 
descendants (not only in TCustomBufDataSet but also in TParadox, 
TMemDataset,  TFixedFormatDataSet,  TDbf) to completelly fix 'missing 
onvalidate call' problem.
Thanks

Laco.




More information about the fpc-devel mailing list