[Gtk-sharp-list] Object destruction

Thorsten Schoel thorsten.schoel at lycos.de
Sun Jul 16 06:38:23 EDT 2006


I stumbled upon a behaviour of Gtk# that seems to be quite problematic
to me:

When a Widget is removed from a container and no more obvious references
to it exist it is still not destroyed. No Destroy or DestroyEvent event
is emitted. Also if you encapsulate a widget in a new class its
destructor isn't called, even after a call to System.GC.Sollect(). This
is in contrast to the same code written in C. I have attached three
examples: test.c showing the (correctly working) C-code, test.cs showing
the (not correctly working) C#-code using a simple Gtk#-object and
test2.cs showing the (not working correctly as well) C#-code using an
encapsulated object - in this last case the destructor is only called
when the whole program exits as its output is

Destructor called!

What the program does is simply remove a button from the window when it's clicked.

My question is if this behaviour is a bug in Gtk# (it would be a rather
serious one in my opinion) or if I made some mistake in my code. Since I am somehow confused about this behaviour of Gtk# I would appreciate any comments that could enlighen me here.

Thank you

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 1301 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060716/43aca814/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cs
Type: text/x-csharp
Size: 1146 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060716/43aca814/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.cs
Type: text/x-csharp
Size: 1428 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060716/43aca814/attachment-0002.bin 

More information about the Gtk-sharp-list mailing list