BUG (causes segv) in tree & list
- From: "Damon Chaplin" <DAChaplin email msn com>
- To: "GTK List" <gtk-list redhat com>
- Subject: BUG (causes segv) in tree & list
- Date: Sun, 22 Mar 1998 22:25:19 -0000
Hi,
A segv occurs if you try to get button_press events from a tree or a list.
(Gtk 0.99.8).
I've included a patch which fixes this, but please check what I've done
as I don't really know what I'm doing (as you may have noticed from
previous messages!)
Here is a test program:
#include <gtk/gtk.h>
gint
button_press(GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_print("In button_press\n");
return TRUE;
}
int
main(int argc, char *argv[])
{
GtkWidget *win, *vbox, *tree, *list, *label;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(win, 160, 220);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (win), vbox);
gtk_widget_show (vbox);
label = gtk_label_new("Tree:");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
tree = gtk_tree_new();
gtk_widget_set_events(tree, gtk_widget_get_events(tree)
| GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (tree), "button_press_event",
GTK_SIGNAL_FUNC(button_press), NULL);
gtk_box_pack_start (GTK_BOX (vbox), tree, TRUE, TRUE, 0);
gtk_widget_show (tree);
label = gtk_label_new("List:");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
list = gtk_list_new();
gtk_widget_set_events(list, gtk_widget_get_events(list)
| GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (list), "button_press_event",
GTK_SIGNAL_FUNC(button_press), NULL);
gtk_box_pack_start (GTK_BOX (vbox), list, TRUE, TRUE, 0);
gtk_widget_show (list);
gtk_widget_show(win);
gtk_main();
return 0;
}
Here are the diffs (my first patch so be very careful!)
--- gtklist.c.orig Sun Mar 22 21:05:59 1998
+++ gtklist.c Sun Mar 22 21:06:03 1998
@@ -698,7 +698,7 @@
list = GTK_LIST (widget);
item = gtk_get_event_widget ((GdkEvent*) event);
- if (!item)
+ if (!item || item == widget)
return FALSE;
while (!gtk_type_is_a (GTK_WIDGET_TYPE (item), gtk_list_item_get_type
()))
--- gtktree.c.orig Sun Mar 22 21:07:02 1998
+++ gtktree.c Sun Mar 22 21:07:05 1998
@@ -299,6 +299,9 @@
tree = GTK_TREE (widget);
item = gtk_get_event_widget ((GdkEvent*) event);
+ if (!item || item == widget)
+ return FALSE;
+
while (!gtk_type_is_a (GTK_WIDGET_TYPE (item), gtk_tree_item_get_type
()))
item = item->parent;
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]