mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 17:39:23 +02:00
lcl: dont call Reset twice in TFieldDataLink.SetFieldName. part of 20032
git-svn-id: trunk@32247 -
This commit is contained in:
parent
0cb8b8da72
commit
f3478d3918
@ -1390,41 +1390,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
Set the FieldName and then update the field to match,
|
Set the FieldName and then notify the changes though EditingChanged and Reset
|
||||||
|
Ensure FField is nil if something goes wrong or FieldName is empty
|
||||||
If we are changing the field from a previously valid field
|
|
||||||
we need to make sure the editing state is updated, and that the
|
|
||||||
DataChanged method is called, easiest way I think is to set the field
|
|
||||||
to nil then call EditingChanged and Reset before we actually set the
|
|
||||||
proper field. This way if this turns out to be an invalid fieldname we
|
|
||||||
are already nil anyway and all the changes to state have been made.
|
|
||||||
|
|
||||||
Next we look up the FieldByName on the attatched DataSource.. which we have
|
|
||||||
to make sure exists first. assuming this worked properly, then we will have a
|
|
||||||
valid Field again, so now we need to update the Editing state again
|
|
||||||
and call the DataChanged again, so Reset. And then we are done... I think.
|
|
||||||
|
|
||||||
If I am missing anything or am doing this all wrong please fix :)
|
|
||||||
}
|
}
|
||||||
procedure TFieldDataLink.SetFieldName(const Value: string);
|
procedure TFieldDataLink.SetFieldName(const Value: string);
|
||||||
begin
|
begin
|
||||||
if FFieldName <> Value then
|
if FFieldName <> Value then
|
||||||
begin
|
begin
|
||||||
FFieldName := Value;
|
FFieldName := Value;
|
||||||
If Assigned(FField) then begin
|
FField := nil;
|
||||||
FField := nil;
|
if (Value <> '') and Assigned(DataSource) and Assigned(DataSource.DataSet) then
|
||||||
EditingChanged;
|
FField := DataSource.DataSet.FieldByName(Value);
|
||||||
Reset;
|
EditingChanged;
|
||||||
end;
|
Reset;
|
||||||
if (Value = '') then
|
|
||||||
Exit;
|
|
||||||
If Assigned(DataSource) and Assigned(DataSource.DataSet) then
|
|
||||||
FField := DataSource.DataSet.FieldByName(FFieldName);
|
|
||||||
|
|
||||||
If Assigned(FField) then begin
|
|
||||||
EditingChanged;
|
|
||||||
Reset;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user