[Gtk-sharp-list] Glade# attribute problem

Lee Mallabone gnome@fonicmonkey.net
07 Apr 2003 22:05:33 +0100

On Mon, 2003-04-07 at 15:15, Mark Derricutt wrote:
> Sweeet - that compiles now.  Although still gives me null pointer 
> exceptions when I have code that refers to the widget after the autoconnect:
> in <0x00064> 00 GladeSamples.GladeTest:.ctor (string[])

This is a slightly weird one, though I think problems occur in the following situation:

1. You have member variables with [GladeWidget] attributes
2. You call Autoconnect in a constructor
3. You try and access the relevant GladeWidget members within that constructor.

It looks like that's what you're doing. I've seen weird behaviour with NullRefs in the same situation myself.

I've never reported it as a bug because I still haven't totally got my head around the reason it happens. It seems entirely possible that your members aren't initialised until the constructor has completely finished, so accessing them *in* the constructor may lead to weirdness.

However, whether that's "a bug" or just inherent behaviour of the runtime's object/class initialisation I don't know. That's the bit I haven't figured out yet...

So the short answer is that I suspect your problems will go away if you put your calls referring to [GladeWidget] members outside your constructor.