2008-05-05 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Mon, 5 May 2008 15:16:09 +0000 (15:16 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Mon, 5 May 2008 15:16:09 +0000 (15:16 -0000)
* MenuStrip.cs, ToolStrip.cs: Guard against an NRE when pressing
the menu key and there are no items on the menu.
[Fixes bug #386644]

svn path=/trunk/mcs/; revision=102531

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs

index c87799198133ac6bb23fd2321dd596da3cd8346f..00b8b946e966a162930a3657ccf2bda1884b69d4 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-05  Jonathan Pobst  <monkey@jpobst.com>
+
+       * MenuStrip.cs, ToolStrip.cs: Guard against an NRE when pressing
+       the menu key and there are no items on the menu.
+       [Fixes bug #386644]
+
 2008-05-05  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Control.cs: Avoid calling ToString on a string.
index 7bd77a15cfa9fd8df888dcde6ff55bee58412d5a..986ed2b8acc8929593e085c9169bae00a4153a0f 100644 (file)
@@ -200,6 +200,9 @@ namespace System.Windows.Forms
                        ToolStripManager.SetActiveToolStrip (this, true);
                        ToolStripItem tsi = this.SelectNextToolStripItem (null, true);
                        
+                       if (tsi == null)
+                               return false;
+                               
                        if (tsi is MdiControlStrip.SystemMenuItem)
                                this.SelectNextToolStripItem (tsi, true);
                                
index 91d769127af9634d0072a153bd9dd85df1e8e5cd..f8723e11ed8d1a594f27cf1b578f1009d34faf03 100644 (file)
@@ -1573,6 +1573,9 @@ namespace System.Windows.Forms
                {
                        ToolStripItem next_item = this.GetNextItem (start, forward ? ArrowDirection.Right : ArrowDirection.Left);
                        
+                       if (next_item == null)
+                               return next_item;
+                               
                        this.ChangeSelection (next_item);
 
                        if (next_item is ToolStripControlHost)