Re: problem: gtk_image gives critical error



On Tue, Apr 18, 2006 at 03:05:51AM -0700, Deependra Shekhawat wrote:
Hello friends,
This is my code:

struct splash
{
      GtkWidget *splash_image;
};
void func1(void)
{
      GtkWidget *img;
      struct splash p;

This structure is created on stack and exists only until the
function func1 exits.

      img=gtk_image_new();
      p.splash_image=img;     
      
      g_signal_connect(G_OBJECT(button1),
                       "clicked",
                       G_CALLBACK(on_butt_clicked),
                       (gpointer) &p);

Therefore &p becomes invalid immediately after you pass it
to g_signal_connect().

}

void on_butt_clicked(GtkButton *button,gpointer data)
{
      struct splash *ptr;
      ptr=(struct splash *)data;

      //some code is here
      
      //following line gives error at execution time.
gtk_image_set_from_pixbuf(GTK_IMAGE((GtkWidget*)ptr->splash_image),buffer);
}

Error is:
(splash_screen:3549): Gtk-CRITICAL **: file
gtkimage.c: line 772 (gtk_image_set_from_pixbuf):
 assertion `GTK_IS_IMAGE (image)' failed

So, you are accessing some random piece of stack here.

Yeti


--
That's enough.



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