Hi there,
I'm having trouble logging objects that I build myself. The SmartInspect console keeps telling me 'LogObject: AInstance argument has no RTTI'. I do have published properties in the objects in question (As I understand it RTTI information is only available for published properties), but to no avail.
Any thoughts?
Gerben ten Wolde,
Ten Hove ICT
Subscribe to forum
Forum
LogObject troubles
Page: 1
| Author | Post |
|---|---|
|
Gerben
|
#1 Fri Feb 17, 2006 3:11 pm
|
| Guest | |
|
#2 Fri Feb 17, 2006 5:14 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 27
|
Hello,
Additionally to making the properties published you have to inherit from the TPersistent class to get RTTI data associated with a class in Delphi. Just adding TPersistent as the base class should do the trick. Hope that helps! _______________ Dennis Gurock, Co-Founder Gurock Software GmbH |
|
Gerben
|
#3 Wed Feb 22, 2006 11:22 am
|
| Guest |
Thanks, that solved it.
|
|
Jeremy Brown
|
#4 Tue Mar 21, 2006 2:32 pm
|
| Guest |
Another way to add the RTTI information is by using the $M compiler directive.
Taken from the Delphi 7 help file: A class cannot have published members unless it is compiled in the {$M+} state or descends from a class compiled in the {$M+} state. Most classes with published members derive from TPersistent, which is compiled in the {$M+} state, so it is seldom necessary to use the $M directive. Example: unit uSomeObject; interface uses Classes; {M+} type TSomeObject = class(TObject) private FCaption; { Private Declarations } protected procedure SetCaption(AValue: string); function GetCaption: string; { ProtectedDeclarations } public { Public Declarations } published property Caption: string read GetCaption write SetCaption; { Published Declarations } end; For more information see the topic "Published members" in the Delphi 7 help file. |
|
Jeremy Brown
|
#5 Tue Mar 21, 2006 2:34 pm
|
| Guest |
Well, bummer. The forum doesn't allow leading spaces. Also my example has a mistake. {M+} should have been {$M+}
|
Page: 1