Re: Error in gtk_text_buffer_insert()?



On Sun, 28 Jul 2002, Matthew Walker wrote:

I'm working on converting a project from GTK 1.2 to 2.0, and I'm running
into a segfault while using gtk_text_buffer_insert(). I've included the
function where the segfault is occuring. If you need more information, let
me know.

(If you see any other problems, feel free to point them out too...)

This is a read handler on a network socket.

gint network_read ( gpointer data,
                    gint source,
                    GdkInputCondition condition)
{
  gchar buff[1025];
  int read_bytes = 1024;
  int got_bytes;

  GtkTextView *output_view = (GtkTextView *)WorldList[(int)data].output_text;
  GtkTextBuffer *output_buffer = gtk_text_view_get_buffer(output_view);
  gtk_text_buffer_get_end_iter(output_buffer,
                               WorldList[(int)data].output_end_iter);

Couple of thoughts:

Can you really do that (int) cast on "data"?  Perhaps you need
GINT_TO_POINTER() in the caller and GPOINTER_TO_INT() in
network_read()?

What is the type of WorldList[].output_end_iter?  From the context it
has to be pointer-to-GtkTextIter, and storage for the Iter must have
been allocated somehow.

Allin Cottrell.




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