[lazarus] Problem

Shane Miller SMiller1 at stvgb.org
Wed May 5 12:10:40 EDT 1999


You are correct that if we create a fmEditor value as we were in TEditor and assign it to self, then everytime we create another one, fmeditor will lose it's prior value and be assigned something new.  Here's the issue though, if you try to access CAPTION like Writeln(Caption) then you get a sigsegv or when you try to access ANY value through SELF.

Perhaps it is an issue with the compiler.  I commented out all the fmeditor stuff and now none of it works when I try to use SELF.  It simply crashes.....

Shane


>>> "Michael A. Hess" <mhess at miraclec.com> 05/05 9:59 AM >>>
Shane Miller wrote:
> 
> I am getting some errors when I don't think I should be and am asking for ideas.  Herre's an example.
> 
> In Editor.pp I have the following declaration:
> 
> TEditor  = class(TForm)
>   public
>   Memo1 : TMemo
>   PageControl1 : TPageControl;
>  TabSheet1 : TTabSheet;
>  end;

<snip>

I don't know if this relates but I have noticed one problem. In main.pp
in TForm1 you define a public variable fmEditor. This is loaded with the
return value of the TEditor.Create call. Fine and dandy. However, in the
editor.pp code you also declare a global variable as fmEditor. I can't
see yet were this might cause the confusion you are getting. I see then
in the TEditor.Create you set the global fmEditor := Self;

In your current configuration you are then using the global fmEditor
internally in the TEditor class. This is a no-no. This means you can
only every have one instance of TEditor. If you try to create another
instance of TEditor it overrights the value in the global fmEditor. Now
if the first instance of TEditor tries to access one of it's methods the
fmEditor value it will attempt to use will be the one from the second
instance of TEditor. This would REALLY mess things up. You should be
using self in all of these locations. This in fact would only be
required in the Create(self) calls. Where you use it to access
properties of TEditor you don't need to add it at all since it will
assume to use the properties from the class where the method is located.

I have another question.

Why are you using {$I+ Strings.inc) in stdcontrols.pp? Why don't you
just add the strings unit to the uses clause?

At this point I think the problem you are seeing is indeed a compiler
error but I will look at the code some more.

Talk at you later,
-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com 

_________________________________________________________________
     To unsubscribe: mail lazarus-request at miraclec.com with
                "unsubscribe" as the Subject






More information about the Lazarus mailing list