Subscribe to forum RSS Forum

LogObject troubles

New Topic Post Reply

Page: 1

Author Post
Gerben
Guest
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
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
Guest
Thanks, that solved it.
Jeremy Brown
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
Guest
Well, bummer. The forum doesn't allow leading spaces. Also my example has a mistake. {M+} should have been {$M+}

New Topic Post Reply

Page: 1