On Mon, 19 Sep 2005 22:18:30 +0300
Alexander Todorov <[EMAIL PROTECTED]> wrote:
> Hi all,
> yestarday I had an annoying problem with Kylix 3 at work and decided
> to try if this happens in Lazarus. The situation is the following :
> ------------------------------------------------------------------------
> { TBaseObject - a base class (3rd party component) }
>
> TBaseObject = class (TObject)
> protected
> FObject : TObject;
> public
> constructor Create;
> destructor Destroy; override;
> end;
>
> { TPubObject - my own class that has a public property to access the
> data
> object from the parent class.}
>
> TPubObject = class (TBaseObject)
> public
> procedure Foo;
> property Obj : TObject read FObject;
> end;
> --------------------------------------------------------
> When I pressed Ctrl+Shift+C to get
>
> procedure TPubObject.Foo;
> begin
>
> end;
>
> The procedure body was created but there was added and the following
> declaration
> TPubObject = class (TBaseObject)
> // diff ---------------------------------------
> private
> FObject: TObject;
> // diff ---------------------------------------
> public
> procedure Foo;
> property Obj : TObject read FObject;
> end;
> ----------------------------------------------------------
>
> On Kylix that compiles and runs without errors and when you execute
> MyObject.Obj.DoSomething you get an access violation because Obj = nil.
> It reads Self.FObject not ParentClass.FObject.
>
> On Lazarus this happens too, but result in compilation error :
> 'duplicate identifier FObject'
>
> Is this a bug in code completion or a setting ? If yes where to report it
> ? Can code complete check the data members in the base class and decide
> what to do or even better ask you what to do (some settings required
> perhaps)?
Class completion in Lazarus reads at the moment only the class definition
and does not search for the ancestors. Advantages are speed and it works on
units, that are incomplete (e.g. has errors or used units can not be found
or parsed). The only disadvantage is the case above, where you really want
to use a former protected member, instead of creating a new.
You can submit a feature request in the bug tracker for an option to let
class completion check members in ancestors.
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives