[gtk-mac-integration] Fix unhandled exception from attempting to access menu itemAtIndex:-1



commit cd3a21ff115cd6c6c11ce39aa62eaf912c78b060
Author: John Ralls <jralls ceridwen us>
Date:   Mon Dec 30 12:20:26 2013 -0800

    Fix unhandled exception from attempting to access menu itemAtIndex:-1

 src/cocoa_menu_item.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/cocoa_menu_item.c b/src/cocoa_menu_item.c
index 793c254..dd46586 100644
--- a/src/cocoa_menu_item.c
+++ b/src/cocoa_menu_item.c
@@ -550,12 +550,16 @@ cocoa_menu_item_add_item (NSMenu* cocoa_menu, GtkWidget* menu_item, int index)
       /* Clean up adjacent separators: */
       if ([cocoa_menu numberOfItems] > 0)
        {
-         if (([cocoa_menu numberOfItems] == index ||
-              [[cocoa_menu itemAtIndex: index] isSeparatorItem]) &&
-             [[cocoa_menu itemAtIndex: index - 1] isSeparatorItem])
+         if (index == 0)
+           {
+             if ([[cocoa_menu itemAtIndex: index] isSeparatorItem])
+               [cocoa_menu removeItemAtIndex: index];
+           }
+         else if (([cocoa_menu numberOfItems] == index ||
+                   [[cocoa_menu itemAtIndex: index] isSeparatorItem]) &&
+                  [[cocoa_menu itemAtIndex: index - 1] isSeparatorItem])
            [cocoa_menu removeItemAtIndex: index - 1];
-         if (index == 0 && [[cocoa_menu itemAtIndex: index] isSeparatorItem])
-           [cocoa_menu removeItemAtIndex: index];
+
        }
     }
 


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