Re: segmentation fault

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
  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
  static int i=0;

4. Here you're passing undefined variable to the
draw_brush call.
  draw_brush (widget, x[i], y[i]);
  return TRUE;

Compile your program with -Wall gcc option and fix
all warnings from 

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]);
   return TRUE;

Somewhere in code:
   g_signal_connect (button, "clicked",


Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 

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