tags:

views:

11

answers:

1

Hello,

I need to create GdkPixBuf collection. I try to save pixbufs in GList - mw->disp_list:

GtkTreeIter iter;
int i = 0;

for (i; i < g_list_length(list) - 1; ++i)
{                       
  char* file = image_list_get_current_file_path( list );

  mw->p1 = gdk_pixbuf_new_from_file(file,NULL);
  mw->p1 = scale_pix(mw->p1,128);

  mw->disp_list = g_list_append (mw->disp_list, mw->p1);

  if (!mw->img_list->current->next )
      image_list_get_first(mw->img_list);
  else
      image_list_get_next(mw->img_list);
}

Where p1 - it's GtkPixBuf*.

But when i try to use mw->disp_list in another function i see that it is NULL. What's wrong?

Thank you.

+1  A: 

At the moment I see just one problem, and it is about the loop that should be:

for (i = 0; i < g_list_length(list); ++i)

The problem could be the -1: if list contains 1 element, you do not loop at all, since 1-1 = 0 and 0 < 0 is false.

ShinTakezou