Re: Explicitly removing bonobo controls
"Nickolay V. Shmyrev" <[email protected]> Fri, 17 Feb 2006 18:55:03 +0300 (MSK)
| Newsgroups | gmane.comp.gnome.components |
|---|---|
| Message-ID | <[email protected]> |
--------------Boundary-00=_RJ9UASBXFQQMYJ0CCJD0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit > >Hi, > >I'm currently writing an application that makes use of bonobo controls. I'm >using bonobo_widget_new_control_async() and related functions to load controls >in my application. Eventually I need to destroy explicitly the widget that >displays the control. As what I get from loading the control is a BonoboWidget, >which in turn is a GtkWidget, I thought that simply using gtk_widget_destroy() >would destroy the widget containing it and properly release the control: > > widget = bonobo_widget_new_control_async (...); > > /* > * Later... > */ > > gtk_widget_destroy (widget); > >However, I noticed that after the call to gtk_widget_destroy() the control >process is still running on the background, which makes me think that I forgot >to release some kind of "reference" to it. The only things I do with the bonobo >widget is getting the control frame and the popup UI component (which I release >properly before trying to destroy the widget): > > widget = bonobo_widget_new_control_async (...); > > /* > * Do the following when the async callback gets called... > */ > > frame = bonobo_widget_get_control_frame (widget, ...); > uic = bonobo_control_frame_get_popup_component (frame, ...); > > /* > * Later... > */ > > bonobo_object_unref (uic); > gtk_widget_destroy (widget); > >I imagine I must be missing something, but I don't know what and I couldn't find >any documentation or examples on it. One of the things I've deeply looked at was >the gnome-panel sources (especially the part related to loading/unloading >applets). I've seen that it explicitly releases the CORBA object using >CORBA_Object_release(). However it doesn't use >bonobo_widget_new_control_async(), instead it uses >bonobo_widget_new_control_from_objref(), so I'm still not sure about that to do. > >Could anyone help me with this? > >Thanks in advance! >Adriano Hi Adriano You've found a leak in bonobo_widget code. Actually there is control_new_async_cb in bonobo-widget.c function that should unref control when everything is done. Or you can do it manually in callback. See the example I've wrote for you. Please file a bug about that, patch is also welcome. Actually we have another long-standing problem - bonobo object leak in filechooser, so every control that runs filechooser will never exit. I wish someone find a time to add one line fix for http://bugzilla.gnome.org/show_bug.cgi?id=145200 --------------Boundary-00=_RJ9UASBXFQQMYJ0CCJD0 Content-Disposition: attachment; Filename="test-control.c" Content-Type: application/octet-stream; name="test-control.c" Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8bGliYm9ub2JvdWkuaD4KCiNpZm5kZWYgU1lO QwoKc3RhdGljIHZvaWQKZGlzcGxheV9jb250cm9sX2FzeW5jX2NiIChCb25vYm9XaWRnZXQgICAg ICAgKndpZGdldCwKCQkJICBDT1JCQV9FbnZpcm9ubWVudCAgKmV2LAoJCQkgIGdwb2ludGVyICAg ICAgICAgICAgdXNlcl9kYXRhKQp7CiAgICBib25vYm9fb2JqZWN0X3JlbGVhc2VfdW5yZWYgKGJv bm9ib193aWRnZXRfZ2V0X29ianJlZiAod2lkZ2V0KSwgTlVMTCk7Cn0KCiNlbmRpZgoKaW50Cm1h aW4gKGludCBhcmdjLCBjaGFyICoqYXJndikKewoJR3RrV2lkZ2V0ICp3aW5kb3c7CglHdGtXaWRn ZXQgKndpZGdldDsKCUJvbm9ib19Db250cm9sIGNvbnRyb2w7CgoJaWYgKCFib25vYm9fdWlfaW5p dCAoInRlc3QiLCAiMC4wIiwgJmFyZ2MsIGFyZ3YpKQoJCWdfZXJyb3IgKCJDYW4gbm90IGJvbm9i b191aV9pbml0Iik7CgoJYm9ub2JvX2FjdGl2YXRlICgpOwoKCXdpbmRvdyA9IGd0a193aW5kb3df bmV3IChHVEtfV0lORE9XX1RPUExFVkVMKTsKCWd0a193aW5kb3dfc2V0X3RpdGxlIChHVEtfV0lO RE9XICh3aW5kb3cpLCAiQ29udHJvbCB0ZXN0Iik7CgoJZ3RrX3dpZGdldF9zaG93X2FsbCAod2lu ZG93KTsKCiNpZmRlZiBTWU5DCgl3aWRnZXQgPSBib25vYm9fd2lkZ2V0X25ld19jb250cm9sICgi T0FGSUlEOkJvbm9ib19TYW1wbGVfRW50cnkiLCBOVUxMKTsKCiNlbHNlIAoKCXdpZGdldCA9IGJv bm9ib193aWRnZXRfbmV3X2NvbnRyb2xfYXN5bmMgKCJPQUZJSUQ6Qm9ub2JvX1NhbXBsZV9FbnRy eSIsIE5VTEwsCgkJCQkJICAJICBkaXNwbGF5X2NvbnRyb2xfYXN5bmNfY2IsIHdpbmRvdyk7CiNl bmRpZgoKCWd0a19jb250YWluZXJfYWRkIChHVEtfQ09OVEFJTkVSICh3aW5kb3cpLCB3aWRnZXQp OwoJCglndGtfd2lkZ2V0X3Nob3dfYWxsICh3aW5kb3cpOwoKCWdfc2lnbmFsX2Nvbm5lY3QgKEdf T0JKRUNUICh3aW5kb3cpLCAiZGVzdHJveSIsIEdfQ0FMTEJBQ0sgKGd0a19tYWluX3F1aXQpLCBO VUxMKTsKCQoJZ3RrX21haW4gKCk7CgoJcmV0dXJuIGJvbm9ib191aV9kZWJ1Z19zaHV0ZG93biAo KTsKfQo= --------------Boundary-00=_RJ9UASBXFQQMYJ0CCJD0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gnome-components-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnome-components-list --------------Boundary-00=_RJ9UASBXFQQMYJ0CCJD0--