[fpc-pascal] Object instance is suddenly corrupt or of unknown type?

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Oct 8 12:38:20 CEST 2009


Hi,

I'm using FPC 2.3.1 on a 64bit Linux system.

I have a field variable which is an class instance. Many methods use
this field variable and it's properties. I suddenly started getting
Access Violations in my application. Adding that field variable to the
Watch Window and stepping through my program I can see the problem.

  Most of the times te watch output is:    FLayout:    TRichTextLayout 0xabcedef

This is correct. The type is known and the memory address seems fine.
(ignore my fake mem address above).

But then at some point the watch output changes to:   FLayout:  ???   0xabcedef

This is to be the problem! I can't seem to find out what cause the
type to be unknown!! :-(  My Access Violation, is because I checked if
FLayout is assigned (which is true even with unknown type) and then
try and Free it, which throws the AV.

At the point where the watch output changes to ???, I ask for a Call
Stack, but the call stack window is incomplete, there are many extra
methods called between the ones listen in the window.... why is that?

Anyway what is the correct way of passing a class instance (object) to
methods? Maybe this is my problem?

eg: Which one is preferred or correct.

FLayout:  TRichTextLayout  (class instance)...  then pass it to other
procedures outside the current class.

Example procedure signature..

procedure TestOne(const ALayout: TRichTextLayout);     <-- currently using this

..or...

procedure TestOne(var ALayout: TRichTextLayout);

..or..

procedure TestOne(ALayout: TRichTextLayout);








-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list