GNOME Bugzilla – Bug 90088
object reference management
Last modified: 2004-12-22 21:47:04 UTC
Something seems to have changed in the object reference management. After I've changed the usage of g_object_new() to Glib::ConstructParams() in libgnomecanvasmm to get it working again, I noticed that canvas objects are not removed anymore in my application. I can reproduce the problem with simple Gtk Widgets (example attached). It seems that if I delete a manage()'ed object all is ok, but if I delete an object that is not managed()'ed strange things happen. I use manage() if I don't want to care about objects destruction, the container should handle this for me. But if I want control I don't use manage(), I call delete() myself e.g. in the destructor. In my example a label and a button is added to a window. Pressing the button removes the label by calling delete(). If the label is managed()'ed this works fine. If you use the other line in the example where the label is not managed()'ed pressing the button for the first time does nothing, the application segfaults if you press a second time.
Created attachment 10331 [details] Example to reproduce the problem
I've added this to the tests directory, and I will investigate later. You don't need to tell me how memory management should work.
I uncommented some code. Before you gave us this test I didn't know why we need it. Well done. 2002-08-10 Murray Cumming <murrayc@usa.net> * gtk/src/object.ccg (destroy_c_instance_()): If g_object_unref() doesn't cause it to be disposed then force it with gtk_object_destroy(). This is necessary because adding a widget to a container refs it even if it's not floating. Fixes bug #90088, as seem in tests/delete_cpp_child.