I'm using libnotify to show desktop notifications; Notification notification
, which should be passed as the first param to call the function next to the Notification Library.
No notify_notification_free ()
returns returns to the pointer. I looked at the source of notify_notification_new ()
and internally it does g_object_new ()
, gets a GObject * and it NotfiyNotification *
, so when my application clears, give me g_object_unref ()
to notify_notification_new ()
?
Yes, unless the reference is "floating" initially in subclasses Use blurry
floating references; The most common use is GTK widgets.
When you create a GTK widget using a gtk_whatever_new ()
function, it is a reference that is marked as Floating when you add a widget to a container , The container should also be placed in the context of the widget. But instead of calling g_object_ref ()
on the widget and increasing the reference number of 2, it "sinks" the floating reference of the object and converts it to a general context. You can say that the container is now the "owner" of the widget.
Then when you delete the container, it calls g_object_unref ()
on the widget, and the reference number becomes zero, and the widget is destroyed. In this way you are not responsible for destroying it yourself.
with the usual GObject
s, which usually does not go to containers, there is no transfer of ownership. When you are working with them, they have to pamper themselves.
Comments
Post a Comment