[patch] optionmenu with no items




Here is a patch to keep the optionmenu widget from crashing when
it's associated menu has no items. (OK, that's a pretty useless
situation...)

diff -c -r -P -X patch-exclude gtk+owt-071997/gtk/gtkoptionmenu.c gtk+/gtk/gtkoptionmenu.c
*** gtk+owt-071997/gtk/gtkoptionmenu.c	Fri Jun  6 03:01:53 1997
--- gtk+/gtk/gtkoptionmenu.c	Sun Jul 27 02:47:37 1997
***************
*** 370,375 ****
--- 370,377 ----
  	    return FALSE;
  	  gtk_option_menu_update_contents (GTK_OPTION_MENU (widget));
  	  child = GTK_BUTTON (widget)->child;
+ 	  if (!child)
+ 	    return FALSE;
  	  remove_child = TRUE;
  	}
  
***************
*** 534,540 ****
    children = GTK_MENU_SHELL (option_menu->menu)->children;
    gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
  
!   menu_ypos += (GTK_WIDGET (option_menu)->allocation.height - active->requisition.height) / 2 - 2;
  
    while (children)
      {
--- 536,545 ----
    children = GTK_MENU_SHELL (option_menu->menu)->children;
    gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
  
!   menu_ypos += GTK_WIDGET (option_menu)->allocation.height / 2 - 2;
!   
!   if (active != NULL)
!     menu_ypos -= active->requisition.height / 2;
  
    while (children)
      {



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