segmentation fault



hi everyone,

  i'm trying to modify the scribble-simple to do the
following:

#include <gtk/gtk.h>
#define N 50

double x[50], y[50];

static void draw_brush( GtkWidget *widget,
                        gdouble    x,
                        gdouble    y )
{
  GdkRectangle update_rect;

  update_rect.x = x - 5;
  update_rect.y = y - 5;
  update_rect.width = 10;
  update_rect.height = 10;
  gdk_draw_rectangle (pixmap,
          widget->style->black_gc,
          TRUE,
          update_rect.x, update_rect.y,
          update_rect.width, update_rect.height);
  gtk_widget_queue_draw_area (widget,
          update_rect.x, update_rect.y,
          update_rect.width, update_rect.height);
}

void draw_button_clicked ( void )
{
  g_timeout_add (100, real_draw, NULL);
}

static gint real_draw ( gpointer window )
{
  GtkWidget *widget;
  static int i=0;

  draw_brush (widget, x[i], y[i]);
  i++;
  return TRUE;
}

in this case, each time i clicked on draw button,
program will start to draw using points stored in x
and y array. but each time i run the program, i will
get segmentation fault. does anyone know why?

thank you all for your help!


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250



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