[lazarus] designer.inc file error

Marc Weustink Marc.Weustink at cuperus.nl
Wed Mar 22 06:02:10 EST 2000


+ From: Michael A. Hess [mailto:mhess at miraclec.com]

[snip]

+ You are attempting to access a protected unit in a class from a
+ different unit. If you note the definition of protected says that,
+
+     "members of a Protected section are also accessible to descendent
+      types, even if they are implemented in other modules"
+
+ In this case TCustomForm can access it's own protected member even
+ though it is located in a different unit BUT TDesigner which is not a
+ descendent can't access a protected member of TCustomForm which it
+ inherited from a different unit.
+
+ Got that.   :-)

Yes, this is how it is implemented now, but if you look at he docs another
interpertation is possible. It says:
1) protected is the same as private (with a more visible scope)

2) private members can only be accessed in the module (i.e. unit)
   that contains the class definition.
   They can be accessed from inside the classes' methods or from
   outside them (e.g. from other classes' methods)

So 2) also counts for protected. I read this as

3) protected members can only be accessed in the module (i.e. unit)
   that contains the class definition or the module (i.e. unit)
   containig the descendent definition.
   They can be accessed from inside the classes' methods or from
   outside them (e.g. from other classes' methods)

Since TCustomForm.IsControl is a protected member of TCustomForm it can be
accessed. That the protected member isn't declared in TCustomForm is another
point, but it is still a protected member. The doc's don't say where the
member should be declared. Besides that this is how Delphi implemented it,
so it should be possible in de delphi mode (I couldn't check it since we
have other problems in delphi mode).

+ If TDesigner and TCustomForm where located in the controls unit then
+ this would work fine. In this case a public member is required in the
+ TCustomForm class to allow TDesigner access.

Or we have to declare thing more public, or we heve to put units together. I
don't like both of them.

Marc






More information about the Lazarus mailing list