problem when setting several times a pixbuf in a gtk image




Hello,

I use the following function to draw a frame in a gtk_image:

static void draw_frame (long int frame_nbr)
{
  GdkPixbuf *pixbuf;
  const BYTE *rgb;
  PClip vclip_rgb32 = ToRGB32::Create(vclip);
  CPVideoFrame frame = vclip_rgb32->GetFrame(frame_nbr);
  guint width = frame->GetDimension().GetWidth();
  guint height = frame->GetDimension().GetHeight();

  rgb = frame->ReadFrom('~').ptr;

  gtk_widget_set_size_request (image, width, height);
  pixbuf = gdk_pixbuf_new_from_data (rgb,
                                     GDK_COLORSPACE_RGB, TRUE,
                                     8, width, height, 4 * width,
                                     (GdkPixbufDestroyNotify) g_free,
                                     (guint8 *)rgb);
  gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
  g_object_unref (G_OBJECT (pixbuf));
}

The first time that I use this function, there's no problem, the pixbuf is
drawn.

But when I call this function another time, it segfault during
gtk_image_set. Does someone see what is wrong ?

thank you

Vincent Torri



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