Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Use of RTTI giving unexplained result


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jan 7, 2015 10:35 AM Last Post By: Markus Humm
Adam Brett

Posts: 9
Registered: 11/18/04
Use of RTTI giving unexplained result  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2015 2:25 AM
I have a set of Form classes where I use RTTI.

At the top of the unit I have the declaration:

{$RTTI EXPLICIT METHODS ([vcPublished])}
{$METHODINFO ON}

I then have code which automatically builds the Menus on each form, depending on the existence of methods on the class

i.e. Class = TCustomer.
published Method:
procedure Print_Statement;

This would produce a "Print Statement" menu item on the form, clicking the item would access the code in "Print_Statement"

--

In a small number of cases non-published methods are being picked up at run time and turned into menu items. Just 1 method (even if there are several on that class) and (so far) only public methods. So far the only instances of the problem involve classes which have no published methods (i.e. should have no menu items)

--

Is this just a bug, or am I doing something wrong?
Anyone else see this behaviour?
Any way to fix it?

oh ... I am using XE2 Enterprise.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Use of RTTI giving unexplained result  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2015 10:14 AM   in response to: Adam Brett in response to: Adam Brett
Adam wrote:

In a small number of cases non-published methods are being picked
up at run time and turned into menu items.

The only way that can happen is if you are using Extended RTTI via the Rtti.pas
unit, since classic RTTI via the TypInfo.pas unit does not include non-published
items. Extended RTTI includes just about everything (private, public, and
everything in between).

If you are really only interested in published items, either switch to classic
RTTI, or use the TRttiMember.Visibility property to ignore items that are
not published.

Is this just a bug, or am I doing something wrong?

You did not show your code, so there is no way to answer that.

--
Remy Lebeau (TeamB)
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Use of RTTI giving unexplained result  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2015 10:35 AM   in response to: Adam Brett in response to: Adam Brett
Am 07.01.2015 um 11:25 schrieb Adam Brett:
I have a set of Form classes where I use RTTI.

At the top of the unit I have the declaration:

{$RTTI EXPLICIT METHODS ([vcPublished])}
{$METHODINFO ON}

I then have code which automatically builds the Menus on each form, depending on the existence of methods on the class

i.e. Class = TCustomer.
published Method:
procedure Print_Statement;

This would produce a "Print Statement" menu item on the form, clicking the item would access the code in "Print_Statement"

--

In a small number of cases non-published methods are being picked up at run time and turned into menu items. Just 1 method (even if there are several on that class) and (so far) only public methods. So far the only instances of the problem involve classes which have no published methods (i.e. should have no menu items)

--

Is this just a bug, or am I doing something wrong?
Anyone else see this behaviour?
Any way to fix it?

oh ... I am using XE2 Enterprise.

Hello,

you should ask this over in the rtl group.
You'll get more and better answers there I guess and thus I've set a
follow up to this answer so that new NNTP based answers appear in the
other group (.rtl) instead of here.

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02