Re: Question about pixbuf
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-list <gtk-list gnome org>
- Subject: Re: Question about pixbuf
- Date: Thu, 01 May 2008 07:36:45 +0100
On Wed, 2008-04-30 at 19:10 -0500, Moises wrote:
> when I use g_object_unref decreases reference count
> and when this hit 0, the object is released, but when
> does it hit 0?
when the last reference, created by the construction of an object, is
removed.
instance = g_object_new (type, ...);
...
g_object_unref (instance); /* the object is disposed */
> when the program ends and eventually
> released all memory or immediately that I used
> g_object_unref?.
if g_object_unref() has been called and it was the last reference then
the object is disposed and the instance becomes a pointer to an invalid
object.
> because apparently does not work because I have the
> following
>
> imgPixbuf = gdk_pixbuf_new_from_file(xfileName,
> error);
> ...
> g_object_unref (imgPixbuf);
>
> but still I get data of pixbuf with:
you are get garbage, which does not segfault on you for a simple matter
of chance. unless the "..." in between did not increase the reference
count of the object.
> imgPixbuf = gdk_pixbuf_new_from_file(xfileName,
> error);
> ...
> g_object_unref (imgPixbuf);
> width=gdk_pixbuf_get_width(imgPixbuf);
>
> then the object is not destroyed
the object is disposed, but not set to NULL. no free/dispose function
will set the pointer to NULL for you - at least, not in GLib.
ciao,
Emmanuele.
--
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]