After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 90088 - object reference management
object reference management
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other other
: Normal major
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-08-07 08:35 UTC by Andreas Holzmann
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example to reproduce the problem (948 bytes, text/plain)
2002-08-07 08:36 UTC, Andreas Holzmann
Details

Description Andreas Holzmann 2002-08-07 08:35:53 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.
Comment 1 Andreas Holzmann 2002-08-07 08:36:55 UTC
Created attachment 10331 [details]
Example to reproduce the problem
Comment 2 Murray Cumming 2002-08-07 18:37:08 UTC
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.
Comment 3 Murray Cumming 2002-08-10 17:40:13 UTC
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.