Re: error message: window != NULL - what's up?




Nathan Froyd <maestrox@geocities.com> writes:

> I create a drawing area w/ gtk_drawing_area_new and try to draw into it
> (actually - obtain a gc) after a call to gtk_widget_show. GTK+ catches a
> core dump. How can I draw into a widget before the whole window of the
> app gets realized?

Drawing into the window is not recommended at this point, since
the window is not on screen yet. You probably should be doing the
drawing in the "expose_event" handler. So you could just create
your gc there (at which point widget->window will be non-NULL)

The other alternative, would be to force-realize the drawing_area
after creation.

  darea = gtk_drawing_area_new ();
  gtk_box_pack_start (GTK_BOX(parent), darea, ...)
  gtk_widget_realize (darea)

[ your parent needs to be added to its parent at this point, and
  so on until you get to a toplevel window ]

This forces the creation of widget->window, so you can now use
that.

Regards,
                                        Owen

  



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