[lazarus] initialized objects?
Baeseman, Cliff
Cliff.Baeseman at greenheck.com
Mon May 17 14:59:47 EDT 1999
I wish it were my code that was causing the problem
but it is also shane that is having trouble with the exact
same thing as well as michael H.
Self is also being affected sometiomes its ok and sometimes it is not..
It is just like or refs are getting blown away.
Cliff
-----Original Message-----
From: nico at clubdelphi.com [mailto:nico at clubdelphi.com]
Sent: Monday, May 17, 1999 2:48 PM
To: lazarus at miraclec.com
Subject: [lazarus] initialized objects?
Hello,
On Sun, 16 May 1999 23:09:59 -0500, you wrote:
>TMyObj.this;
>begin
> edit := TEdit.Create(Self);
>edit.text := 'this works' <-----this works just fine
>end;
>TMyObj.that;
>begin
>edit.Text := 'not cool'; <-----this is throwing a access violation ?
>end;
>I have checked everything I can possibly think of and cannot get stuff
>like this to work. I have been fighting access violations all day.
>If I check for assigned it evaluates true. Like the pointers are
>getting hosed up..
Cliff, "Assigned" only tell you that the pointer isn't nil. It can't
tell you if the address is valid.
I'm *not sure*... but I think that, at least in Delphi, you can trust
that global variables are initialized to nil (all zeroes).
Object fields are also nil if the object constructor executes
TObject.Create first, which zero all fields. If not, you can't tell
which the initial value will be, unless you explicitely assign nil in
your constructor.
Local variables are never guarranteed to be nil cause they're taken
from the stack, that dynamically holds return addresses, parameters
and so on.
For object variables whose lifetime is longer than a function is a
good programming practice (but by no means forced) to assign nil just
after calling Free. Assigning nil in the constructor also helps to
avoid errors. I encourage you to take this precautions at least while
developing.
I'm overworked now and most likely I will, during next three or four
weeks. I hope to stay in touch, though
greetings
Nico
_________________________________________________________________
To unsubscribe: mail lazarus-request at miraclec.com with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus
More information about the Lazarus
mailing list