This fixes a segmentation fault with removing items from menus. Before
this change, the list of container items retrieved from the Menu were
always null (or of size 1) because we were not looking in the submenu.
Whether or not the Menu is created with a title, it is created inside a
submenu.

This has been tested for menus/popups that have titles and those that
don't.

Unfortunately, mouse events for the right button is not working well (i
am working on this), so in some cases the popup menu will not stay open
when the right-button has been released (if it has been told to). The
MouseEvent.MOUSE_RELEASED event is not dispatched for the right
button :(

2006-03-02  Lillian Angel <[EMAIL PROTECTED]>

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
        (Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem): Changed to
        use the submenu to get the list of children. This now works
        in the same way as addItem.

Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c,v
retrieving revision 1.20
diff -u -r1.20 gnu_java_awt_peer_gtk_GtkMenuPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c	22 Sep 2005 20:25:39 -0000	1.20
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c	2 Mar 2006 20:29:28 -0000
@@ -160,14 +160,17 @@
 {
   void *ptr;
   GList *list;
-
+  GtkMenu *menu;
+  
   gdk_threads_enter ();
 
   ptr = NSA_GET_PTR (env, obj);
 
-  list = gtk_container_get_children (GTK_CONTAINER (ptr));
+  menu = GTK_MENU (gtk_menu_item_get_submenu(GTK_MENU_ITEM(ptr)));
+
+  list = gtk_container_get_children (GTK_CONTAINER (menu));
   list = g_list_nth (list, index);
-  gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data));
+  gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET (list->data));
 
   gdk_threads_leave ();
 }

Reply via email to