[fpc-devel] restbase.pp LoadFromJSON calling StopRecordPropertyChanges;
Wayne Sherman
wsherman at gmail.com
Sat Jan 14 06:17:20 CET 2023
Is there a better way to track changed TBaseObject properties (and get
rid of property index declarations)?
Lazarus knows which properties on a form have been changed from their
default value and only properties which do not match the default are
saved in the lfm file. Can the same thing be used with TBaseObject
properties?
On Fri, Jan 13, 2023 at 8:59 PM Wayne Sherman <wsherman at gmail.com> wrote:
>
> Some related misunderstandings:
>
> 1) When StopRecordPropertyChanges is called it destroys all the
> change records (stored in TBits) in which case SaveToJSON saves ALL
> the properties even if they were not loaded or modified previously.
>
> 2) Nothing in restbase.pp or TBaseObject calls MarkPropertyChanged
> anyway, so no properties will get marked as modified during
> TGoogleRestDescription.LoadFromJSON.
>
> procedure TBaseObject.MarkPropertyChanged(AIndex: Integer);
> begin
> If Assigned(FBits) then
> FBits.SetOn(GetParentPropCount+(AIndex shr IndexShift));
> end;
>
> 3) Both MarkPropertyChanged (above) and IsPropertyModified (below)
> require the properties declarations to have indexes and
> TGoogleRestDescription does not have indexes on any of its properties.
>
> function TBaseObject.IsPropertyModified(Info: PPropInfo): Boolean;
> begin
> Result:=Not Assigned(FBits) or FBits.Bits[Info^.NameIndex]
> end;
More information about the fpc-devel
mailing list