Re: Clarification on when to unref pixbufs -GtkIconView

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-05-18 at 07:49 -0700, Paul Stuart wrote:

>   .
>    newPixBuf    = gdk_pixbuf_new_from_file ("myImage.png", &err);
>    scaledPixBuf = gdk_pixbuf_scale_simple(newPixBuf, ICON_VIEW_W, ICON_VIEW_H, GDK_INTERP_BILINEAR);

As a side note, you can load and scale immediately by using
gdk_pixbuf_new_from_file_at_scale(). This will be more efficient for
some image types.

>     
>    if(NULL == err) { // no error
>         gtk_list_store_append (store, &iter);
>         gtk_list_store_set(store, &iter, COL_PIXBUF0, scaledPixBuf, -1);
>         g_object_unref(scaledPixBuf);
>         g_object_unref(newPixBuf);

Yours is a more generic question than whether you need to do it for
iconviews or not. It has to do with how to manipulate a GObject instance
in liststores/treemodels. In general, any time you set a GObject in a
model, this will own a reference. So, if you don't need your reference,
you can remove it.

On the other way around, when you retrieve a GObject from a model,
you'll own a reference that you need to remove when you are done with
the object.

Claudio


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux