Re: problem: gtk_image gives critical error



Dear,

When I print the address of p in the funcl it prints a

address.
In the callback function it also prints the same for 
ptr.
Then what's the problem.
Also I use structures to pass data all the time to
the callback function then there's no error but with
this image widget there seems any problem.
Please clarify if I have any alternatives 

Regards

--- "David Necas (Yeti)" <yeti physics muni cz> wrote:

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.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



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