Re: segmentation fault
- From: Aaron Yang <porsche1904 yahoo com>
- To: Olexiy Avramchenko <olexiy ctech cn ua>, gtk-app-devel-list gnome org
- Cc:
- Subject: Re: segmentation fault
- Date: Thu, 10 Feb 2005 01:09:34 -0800 (PST)
hi, thanks for replying
after changing, segmentation fault still follows.
there's an additional error saying
warning: passing arg 2 of `g_timeout_add' from
incompatible pointer type
in this case arg 2 is static gint real_draw (
GtkWidget * )
i figure the error occurred because it shd be
static gint real_draw ( gpointer )
but still upon clicking the button,
program terminates with segmentation error. what else
could be the problem? thanks again for your help
--- Olexiy Avramchenko <olexiy ctech cn ua> wrote:
Aaron Yang wrote:
void draw_button_clicked ( void )
{
1. You're passing NULL as a parameter for timeout's
callback.
g_timeout_add (100, real_draw, NULL);
}
2. window parameter is NULL (see above).
static gint real_draw ( gpointer window )
{
GtkWidget *widget;
3. Variable widget is undefined, it can hold any
pointer.
static int i=0;
4. Here you're passing undefined variable to the
draw_brush call.
draw_brush (widget, x[i], y[i]);
i++;
return TRUE;
}
Compile your program with -Wall gcc option and fix
all warnings from
compiler.
To solve your problem you should do smth like this:
void draw_button_clicked ( GtkWidget *button,
GtkWidget *drawing_area )
{
g_timeout_add (100, real_draw, drawing_area);
}
static gint real_draw ( GtkWidget *drawing_area )
{
static int i=0;
draw_brush (widget, x[i], y[i]);
i++;
return TRUE;
}
Somewhere in code:
g_signal_connect (button, "clicked",
G_CALLBACK(draw_button_clicked),
drawing_area);
Olexiy
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]