Possible bug in gtk when using textview
- From: Oliver Rauch <oliver rauch rauch-domain de>
- To: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Possible bug in gtk when using textview
- Date: Wed, 25 Sep 2002 00:00:13 +0200
Hello.
I have a problem with textview:
When I run the attached test program
(compile with "gcc `pkg-config --cflags --libs gtk+-2.0` textview.c")
and do:
- select a part of the text with the mouse
- press the close or the window-destroy button
then the program crashes with a segmentation fault.
When I do not select the text with the mouse
everything works fine.
When I comment out the
gtk_widget_realize(dialog);
in line 34
then everything works fine.
I am not sure if all I do is correct but I think
the program should not crash.
The test is done with gtk-2.0.5.
Please can tell me someone if this is a bug in gtk or
if I am doing something wrong.
Best regards
Oliver
Here are some lines of the backtrace:
(a.out:4218): GLib-GObject-CRITICAL **: file gobject.c: line 1292 (g_object_ref):
assertion `object->ref_count > 0' failed
Program received signal SIGSEGV, Segmentation fault.
0x400d33a4 in g_type_class_meta_marshal (closure=0x8087470, return_value=0x0,
n_param_values=3, param_values=0xbfffb74c, invocation_hint=0xbfffb628,
marshal_data=0x5c) at gclosure.c:511
511 gclosure.c: No such file or directory.
in gclosure.c
(gdb) bt
#0 0x400d33a4 in g_type_class_meta_marshal (closure=0x8087470, return_value=0x0,
n_param_values=3, param_values=0xbfffb74c, invocation_hint=0xbfffb628,
marshal_data=0x5c) at gclosure.c:511
#1 0x400d2fda in g_closure_invoke (closure=0x8087470, return_value=0x0, n_param_values=3,
param_values=0xbfffb74c, invocation_hint=0xbfffb628)
at gclosure.c:437
#2 0x400e7ada in signal_emit_unlocked_R (node=0x8087930, detail=0, instance=0x8087b68,
emission_return=0x0, instance_and_params=0xbfffb74c) at gsignal.c:2379
#3 0x400e5efb in g_signal_emit_valist (instance=0x8087b68, signal_id=106, detail=0,
var_args=0xbfffb8d8) at gsignal.c:2100
#4 0x400e61a9 in g_signal_emit (instance=0x8087b68, signal_id=106, detail=0) at
gsignal.c:2144
#5 0x402f010b in gtk_text_buffer_mark_set (buffer=0x8087b68, location=0xbfffb954,
mark=0x8088d20) at gtktextbuffer.c:1596
#6 0x402f023a in gtk_text_buffer_set_mark (buffer=0x8087b68, existing_mark=0x8088d20,
mark_name=0x0, iter=0xbfffba34, left_gravity=0, should_exist=1)
at gtktextbuffer.c:1649
#7 0x402f03dc in gtk_text_buffer_move_mark (buffer=0x8087b68, mark=0x8088d20,
where=0xbfffba34) at gtktextbuffer.c:1711
#8 0x402f2068 in clipboard_clear_selection_cb (clipboard=0x8088e30, data=0x8087b68) at
gtktextbuffer.c:2610
#9 0x4022766d in clipboard_unset (clipboard=0x8088e30) at gtkclipboard.c:493
#10 0x40226ff9 in selection_clear_event_cb (widget=0x80ead00, event=0xbfffc00c) at
gtkclipboard.c:172
#11 0x4028eaf3 in _gtk_marshal_BOOLEAN__BOXED (closure=0x80e7a78, return_value=0xbfffbcbc,
n_param_values=2, param_values=0xbfffbe0c,
invocation_hint=0xbfffbcd8, marshal_data=0x0) at gtkmarshalers.c:82
#12 0x400d2fda in g_closure_invoke (closure=0x80e7a78, return_value=0xbfffbcbc,
n_param_values=2, param_values=0xbfffbe0c, invocation_hint=0xbfffbcd8)
at gclosure.c:437
#13 0x400e76d4 in signal_emit_unlocked_R (node=0x80680c8, detail=0, instance=0x80ead00,
emission_return=0xbfffbdcc, instance_and_params=0xbfffbe0c)
at gsignal.c:2341
#14 0x400e5f68 in g_signal_emit_valist (instance=0x80ead00, signal_id=40, detail=0,
var_args=0xbfffbf90) at gsignal.c:2110
#15 0x402c6450 in gtk_signal_emit (object=0x80ead00, signal_id=40) at gtksignal.c:355
#16 0x4034bc08 in gtk_widget_event_internal (widget=0x80ead00, event=0xbfffc00c) at
gtkwidget.c:3082
#17 0x4034b863 in gtk_widget_event (widget=0x80ead00, event=0xbfffc00c) at
gtkwidget.c:2943
#18 0x402c1859 in gtk_selection_owner_set (widget=0x0, selection=0x1, time=2112491325) at
gtkselection.c:381
#19 0x402276ed in gtk_clipboard_clear (clipboard=0x8088e30) at gtkclipboard.c:512
#20 0x402f2ba0 in remove_all_selection_clipboards (buffer=0x8087b68) at
gtktextbuffer.c:3156
#21 0x402eda69 in gtk_text_buffer_finalize (object=0x8087b68) at gtktextbuffer.c:345
#22 0x400d4c99 in g_object_last_unref (object=0x8087b68) at gobject.c:436
#23 0x400d8229 in g_object_unref (_object=0x8087b68) at gobject.c:1320
#24 0x402fd4ba in gtk_text_layout_set_buffer (layout=0x807efc8, buffer=0x0) at
gtktextlayout.c:284
#25 0x402fd342 in gtk_text_layout_finalize (object=0x807efc8) at gtktextlayout.c:240
#26 0x400d4c99 in g_object_last_unref (object=0x807efc8) at gobject.c:436
#27 0x400d8229 in g_object_unref (_object=0x807efc8) at gobject.c:1320
#28 0x4030f69d in gtk_text_view_destroy_layout (text_view=0x8083b90) at gtktextview.c:5364
#29 0x4030a9f7 in gtk_text_view_destroy (object=0x8083b90) at gtktextview.c:2408
#30 0x400e8508 in g_cclosure_marshal_VOID__VOID (closure=0x8062490, return_value=0x0,
n_param_values=1, param_values=0xbfffc5dc, invocation_hint=0xbfffc4b8,
marshal_data=0x4030a9c0) at gmarshal.c:77
#31 0x400d33cc in g_type_class_meta_marshal (closure=0x8062490, return_value=0x0,
n_param_values=1, param_values=0xbfffc5dc, invocation_hint=0xbfffc4b8,
marshal_data=0x4c) at gclosure.c:514
#32 0x400d2fda in g_closure_invoke (closure=0x8062490, return_value=0x0, n_param_values=1,
param_values=0xbfffc5dc, invocation_hint=0xbfffc4b8)
at gclosure.c:437
#33 0x400e80fa in signal_emit_unlocked_R (node=0x80624c8, detail=0, instance=0x8083b90,
emission_return=0x0, instance_and_params=0xbfffc5dc) at gsignal.c:2457
#34 0x400e5efb in g_signal_emit_valist (instance=0x8083b90, signal_id=2, detail=0,
var_args=0xbfffc75c) at gsignal.c:2100
#35 0x402c6450 in gtk_signal_emit (object=0x8083b90, signal_id=2) at gtksignal.c:355
#36 0x402a51e3 in gtk_object_dispose (gobject=0x8083b90) at gtkobject.c:373
#37 0x4034fa95 in gtk_widget_dispose (object=0x8083b90) at gtkwidget.c:5605
#38 0x400d4db4 in g_object_run_dispose (object=0x8083b90) at gobject.c:468
#39 0x402a51a6 in gtk_object_destroy (object=0x8083b90) at gtkobject.c:358
#40 0x40349769 in gtk_widget_destroy (widget=0x8083b90) at gtkwidget.c:1581
#41 0x402165f4 in gtk_bin_forall (container=0x807cab0, include_internals=0,
callback=0x8048b38 <gtk_widget_destroy>, callback_data=0x0) at gtkbin.c:165
#42 0x402c0188 in gtk_scrolled_window_forall (container=0x807cab0, include_internals=0,
callback=0x8048b38 <gtk_widget_destroy>, callback_data=0x0)
at gtkscrolledwindow.c:766
#include "gtk/gtk.h"
static int accept_flag;
static GtkWidget *dialog = NULL;
static void delete_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
{
accept_flag = (int) data;
gtk_widget_destroy(dialog);
dialog = NULL;
}
static void button_callback(GtkWidget *widget, gpointer data)
{
accept_flag = (int) data;
gtk_widget_destroy(dialog);
dialog = NULL;
}
/* --------------------------------- */
int main(int argc, char ** argv)
{
GtkWidget *scrolled_window, *text_view;
GtkTextBuffer *text_buffer;
GtkWidget *vbox, *hbox, *button, *label;
gtk_init(&argc, &argv);
dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(dialog, 550, 580);
g_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(delete_callback), (void *) 1);
gtk_widget_realize(dialog);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(dialog), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show(hbox);
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
gtk_widget_show(scrolled_window);
text_view = gtk_text_view_new();
gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
gtk_widget_show(text_view);
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
gtk_text_buffer_insert_at_cursor(text_buffer, "test0---\n", 9);
gtk_text_buffer_insert_at_cursor(text_buffer, "test1\n", 6);
gtk_text_buffer_insert_at_cursor(text_buffer, "test2\n", 6);
gtk_text_buffer_insert_at_cursor(text_buffer, "test3\n", 6);
gtk_text_buffer_insert_at_cursor(text_buffer, "test4\n", 6);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label("Close");
g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) button_callback, (void *) 0);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_show(button);
gtk_widget_show(hbox);
gtk_widget_show(vbox);
gtk_widget_show(dialog);
accept_flag = -1;
while (accept_flag == -1) /* flag is set in callback */
{
gtk_main_iteration();
}
printf("answer = %d\n", accept_flag);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]