Re: When and when not to use Glib::RefPtr?
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc: Matthias Kaeppler <nospam digitalraid com>, Murray Cumming <murrayc murrayc com>
- Subject: Re: When and when not to use Glib::RefPtr?
- Date: Mon, 11 Apr 2005 20:06:49 +0100
On Monday 11 April 2005 01:53, Murray Cumming wrote:
[snip]
> In general we avoid guessing such (undocumented) internal lifetime
> details, and just do the same thing with all GObjects. C coders do
> whatever works, with lots of errors along the way.
Typically, in a case such as this, where the holding of a reference counting
smart pointer is not enough to ensure the usable lifetime of the object, C++
would use a weak pointer.
You are being unkind to C coders. Although glibmm does not provide weak
pointers, C coders have glib, which does: it provides
g_object_add_weak_pointer() ("Adds a weak reference from weak_pointer to
object to indicate that the pointer located at weak_pointer_location is only
valid during the lifetime of object. When the object is finalized,
weak_pointer will be set to NULL"), together with
g_object_remove_weak_pointer(), g_object_weak_ref() and
g_object_weak_unref(), and GWeakNotify(), for the purpose.
The glib weak pointer will tell the user precisely whether the object it
references is valid or not.
Chris.
--
Summer is y-cumen in, lhude sing, cuccu!
Groweth sed and bloweth med, springeth the wude nu.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]