cvs diff: warning: failed to open /root/.cvspass for reading: No such file or directory
Index: NSPopUpButtonCell.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSPopUpButtonCell.m,v
retrieving revision 1.45
diff -u -r1.45 NSPopUpButtonCell.m
--- NSPopUpButtonCell.m	12 Apr 2003 11:12:31 -0000	1.45
+++ NSPopUpButtonCell.m	12 Apr 2003 20:41:16 -0000
@@ -202,11 +202,10 @@
 
 - (void) removeAllItems
 {
-  while ([_menu numberOfItems] > 1)
+  while ([_menu numberOfItems] > 0)
     {
       [_menu removeItemAtIndex: 0];
     }
-  [[_menu itemAtIndex: 0] setTitle: @""];
 }
 
 // Accessing the items
@@ -512,9 +511,34 @@
   if ([[controlView window] gState] == 0)
     return;
 
-  /* Get the NSMenuItemCell of the selected item */
-  aCell = [[_menu menuRepresentation] 
-           menuItemCellForItemAtIndex: [self indexOfSelectedItem]];
+  /* 
+   * Get the NSMenuItemCell of the selected item, or create a temporary 
+   * NSMenuItemCell to atleast draw our control.
+   */
+  if ([_menu numberOfItems] > 0)
+    {
+      aCell = [[_menu menuRepresentation] 
+		menuItemCellForItemAtIndex: [self indexOfSelectedItem]];
+      /* Retain the cell so we can release it later without upsetting the 
+       * reference counting.
+       */
+      RETAIN(aCell);
+    }
+  else
+    {
+      NSMenuItem *anItem = [NSMenuItem new];
+      [anItem setImage: _pbc_image[_pbcFlags.pullsDown]];
+      aCell = [NSMenuItemCell new];
+      /* We need this menu item because NSMenuItemCell gets its contents 
+       * from the menuItem not from what is set in the cell
+       */
+      [aCell setMenuItem: anItem];
+      RELEASE(anItem);
+      /* We need to set the menu view so we trigger the special case 
+       * popupbutton code in NSMenuItemCell
+       */
+      [aCell setMenuView: [_menu menuRepresentation]];
+    }
 
   /* Turn off highlighting so the NSPopUpButton looks right */
   [aCell setHighlighted: NO];
@@ -526,6 +550,9 @@
 
   /* Rehighlight item for consistency */
   [aCell setHighlighted: YES];
+
+  /* Release the cell to restore balance */
+  RELEASE(aCell);
 }
 
 /* FIXME: This needs to be removed in favor of allowing the cell to draw 
