#1 2012-10-31 17:07:22

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Error ObjectToJSON with published object with getter/setter properties

Hi, Delphi20009ent

We have TInterfacedCollection class with internal TPersistent objects.
If we leave plain  syntax without getScale and setScale it's ok. Is this intended?

TCustomScale=Class(TPersistent);


myObject(TInterfacedCollection)
published
....
  property Scaling           : TCustomScale read FScale Write FScale; // this is OK
...

but if I use

....
  property Scaling           : TCustomScale read getScale Write setScale; // access violation
...

Eureka Log:

2.1 Date          : Wed, 31 Oct 2012 17:59:17 +0100
  2.2 Address       : 004D7617
  2.3 Module Name   : EMRASvr.exe
  2.4 Module Version:
  2.5 Type          : EAccessViolation
  2.6 Message       : Access violation at address 004D7617 in module 'EMRASvr.exe'. Read of address 00000000.
  2.7 ID            : 3917
  2.8 Count         : 1
  2.9 Status        : New
  2.10 Note         :

Address    Module    Unit    Class    Procedure/Method    Line    Rel. line   
004CEB52    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21634    3   
004CEB18    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21631    0   
004CF34D    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21884    253   
004CEB18    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21631    0   
004CEE0C    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21718    87   
004CEB18    EMRASvr.exe    SQLite3Commons.pas        JSONToObject    21631    0   

  if (Value=nil) or (PPointer(Value)^=nil) then
    exit;
..
        // will handle '[TCollection...' '[TStrings...' '{TObject...'
        From := JSONToObject(PObject(P^.GetFieldAddr(Value))^,From,NestedValid);

            CollItem := Coll.Add;
            From := JSONToObject(CollItem,From,NestedValid);  <=== access violation (wants to update Scaling object property)

Thank you,
Vojko

Last edited by VojkoCendak (2012-10-31 17:10:29)

Offline

#2 2012-11-01 10:25:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Error ObjectToJSON with published object with getter/setter properties

Yes, this is not implemented.

Objects properties are expected to be stored by value, not using getters/setters.
Custom serialization is to be used if you want more complex streaming.

Offline

#3 2012-11-01 13:23:18

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: Error ObjectToJSON with published object with getter/setter properties

It works with normal properties like integer, string, but not (yet wink ) with classes.
Delphi has GetObjectProp() if TTypeKind = tkClass and get set procedure is <> nil.

thank you,
Vojko

Offline

#4 2013-01-14 16:58:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Error ObjectToJSON with published object with getter/setter properties

A ticket has been created for this issue.

This http://synopse.info/fossil/info/f99c86b1ac

Offline

Board footer

Powered by FluxBB