[fpc-devel] FPC SetDynArrayProp
silvioprog
silvioprog at gmail.com
Mon Nov 28 19:25:37 CET 2016
On Mon, Nov 28, 2016 at 2:31 PM, Ondrej Pokorny <lazarus at kluug.net> wrote:
> On 28.11.2016 17:37, Ondrej Pokorny wrote:
>
>> Is SetObjectProp safe?
>>
>
> OK, no it is not - it doesn't increment the reference count for properties
> without a setter:
> property Data: TBytes write FBytes;
>
> Ondrej
Yes, and it seems you can't handle properties setting field, eg: "property
Data: TBytes read FData write FData".
An workaround just for testing:
procedure SetDynArrayProp(AInstance: TObject; APropInfo: PPropInfo; const
AValue);
begin
// Caution: it works only with fields! But we can implement the full
version checking methods too, getting some ideas from SetRawInterfaceProp
CopyArray(PPointer(Pointer(AInstance)+PtrUInt(APropInfo^.SetProc)),
@AValue, APropInfo^.PropType, 1);
end;
...
// {$IFDEF FPC}
SetDynArrayProp(O, PropInfo, A);
// {$ELSE}
// SetDynArrayProp(O, PropInfo, A);
// {$ENDIF}
...
Anyway including (Get)SetDynArrayProp() to typinfo solve the problem
because it can check if property's set is a field or a method.
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20161128/a987d9d4/attachment.html>
More information about the fpc-devel
mailing list