Clarification on when to unref pixbufs -GtkIconView



Hi,
 I am loading a pixbuf from a file, scaling it and then sticking it into a GtkIconView. A snippet of code:

  .
  .
  .
  .
   newPixBuf    = gdk_pixbuf_new_from_file ("myImage.png", &err);
   scaledPixBuf = gdk_pixbuf_scale_simple(newPixBuf, ICON_VIEW_W, ICON_VIEW_H, GDK_INTERP_BILINEAR);									
    
   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);
  .
  .
  .
  .


Am I correct in calling the g_object_unref after loading it into the list_store? 

Sample code I've seen here and there online doesn't unref the pixbufs, but the documentation seems to indicate one should. 

Thanks!
Paul


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