lcl: call Reset in TFieldDataLink.RecordChanged if aField equal to nil or to FField

keep TFieldDataLink.DataSetChanged only in fpc 242

git-svn-id: trunk@32256 -
This commit is contained in:
blikblum 2011-09-10 16:20:57 +00:00
parent aae1b7e21f
commit cb6c671993

View File

@ -75,7 +75,9 @@ Type
protected protected
// Testing Events // Testing Events
procedure ActiveChanged; override; procedure ActiveChanged; override;
{$IF ((FPC_VERSION = 2) and (FPC_RELEASE = 4) and (FPC_PATCH = 2))}
procedure DataSetChanged; override; procedure DataSetChanged; override;
{$ENDIF}
procedure EditingChanged; override; procedure EditingChanged; override;
procedure LayoutChanged; override; procedure LayoutChanged; override;
procedure RecordChanged(aField: TField); override; procedure RecordChanged(aField: TField); override;
@ -1464,19 +1466,18 @@ begin
FOnActiveChange(Self); FOnActiveChange(Self);
end; end;
{ not in the delphi version(well not int the help anyway) {$IF ((FPC_VERSION = 2) and (FPC_RELEASE = 4) and (FPC_PATCH = 2))}
but the db version is calling RecordChange with nil, {
which is invalid if we have a real value, so just call reset This is not necessary since TDataLink.DatasetChanged calls RecordChanged
Keep for now as a workaround to fpc bug 16428 (LayoutChanged not being called)
The bug is present in fpc 242 (the last LCL supported version) but fixed in fpc 244 and up
} }
procedure TFieldDataLink.DataSetChanged; procedure TFieldDataLink.DataSetChanged;
begin begin
//workaround to fpc bug 16428 (LayoutChanged not being called)
//in some situations (e.g. creating fields at design time) the
//FField can point to an invalid reference leading to a crash
//todo: remove ValidateField after fpc bug 16428 is fixed
ValidateField; ValidateField;
reset; reset;
end; end;
{$ENDIF}
{ Delphi Help -> { Delphi Help ->
@ -1540,24 +1541,17 @@ end;
Applications can not call this protected method. It is triggered Applications can not call this protected method. It is triggered
automatically when the contents of the current record change. automatically when the contents of the current record change.
RecordChanged calls the OnDataChange event handler if there is one. RecordChanged calls the OnDataChange event handler if there is one.
TDataLink.RecordChanged:
The Field parameter indicates which field of the current record has changed in value.
If Field is nil (Delphi) or NULL (C++), any number of fields within the current record may have changed.
<-- Delphi Help <-- Delphi Help
Ok so just a simple Event Handler.. what. no extra tests? we gotta Call Reset if AField = FField or aField = nil
have at least one.. :)
yeah lets go ahead and make sure the field matches the
internal one. can it ever not? and if not what about nil? do we
need to do something special? maybe another test is needed later....
does this only get called after Modified? assume so till I know otherwise
and turn off IsModified.
hah. same thing as Reset but with a test so lets just call Reset and let
it do the work
} }
procedure TFieldDataLink.RecordChanged(aField: TField); procedure TFieldDataLink.RecordChanged(aField: TField);
begin begin
if (aField = FField) then if (aField = nil) or (aField = FField) then
Reset; Reset;
end; end;