Error in gtk_text_buffer_insert()?



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);

  got_bytes = recv(source, buff, read_bytes, 0);

  if (got_bytes > 0) {
    gtk_text_buffer_insert (output_buffer,
                            WorldList[(int)data].output_end_iter,
                            (const gchar *)buff,
                            (gint)got_bytes);
    return TRUE;
  } else {
    gdk_input_remove(WorldList[(int)data].network_read_handler);
    return FALSE;
  }
}





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