comparison src/gui_gtk.c @ 5092:1ed945570d47 v7.3.1289

updated for version 7.3.1289 Problem: Get GLIB warning when removing a menu item. Solution: Reference menu-id and also call gtk_container_remove(). (Ivan Krasilnikov)
author Bram Moolenaar <bram@vim.org>
date Wed, 03 Jul 2013 13:04:27 +0200
parents 337a4368fd2b
children 055a0b587a3e
comparison
equal deleted inserted replaced
5091:310b766002fe 5092:1ed945570d47
611 * Destroy the machine specific menu widget. 611 * Destroy the machine specific menu widget.
612 */ 612 */
613 void 613 void
614 gui_mch_destroy_menu(vimmenu_T *menu) 614 gui_mch_destroy_menu(vimmenu_T *menu)
615 { 615 {
616 /* Don't let gtk_container_remove automatically destroy menu->id. */
617 if (menu->id != NULL)
618 g_object_ref(menu->id);
619
620 /* Workaround for a spurious gtk warning in Ubuntu: "Trying to remove
621 * a child that doesn't believe we're it's parent."
622 * Remove widget from gui.menubar before destroying it. */
623 if (menu->id != NULL && gui.menubar != NULL
624 && gtk_widget_get_parent(menu->id) == gui.menubar)
625 gtk_container_remove(GTK_CONTAINER(gui.menubar), menu->id);
626
616 # ifdef FEAT_TOOLBAR 627 # ifdef FEAT_TOOLBAR
617 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name)) 628 if (menu->parent != NULL && menu_is_toolbar(menu->parent->name))
618 { 629 {
619 if (menu_is_separator(menu->name)) 630 if (menu_is_separator(menu->name))
620 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar), 631 gtk_toolbar_remove_space(GTK_TOOLBAR(gui.toolbar),
630 641
631 if (menu->id != NULL) 642 if (menu->id != NULL)
632 gtk_widget_destroy(menu->id); 643 gtk_widget_destroy(menu->id);
633 } 644 }
634 645
646 if (menu->id != NULL)
647 g_object_unref(menu->id);
635 menu->submenu_id = NULL; 648 menu->submenu_id = NULL;
636 menu->id = NULL; 649 menu->id = NULL;
637 } 650 }
638 #endif /* FEAT_MENU */ 651 #endif /* FEAT_MENU */
639 652