summaryrefslogtreecommitdiffstats
path: root/build-aux/osx/build/modulesets/patches/gtk-mac-integration/0001-Fix-unhandled-exception-from-attempting-to-access-me.patch
blob: 87151bb02d3c0e7b62194e68e72e5b4fff19c543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From cd3a21ff115cd6c6c11ce39aa62eaf912c78b060 Mon Sep 17 00:00:00 2001
From: John Ralls <jralls@ceridwen.us>
Date: Mon, 30 Dec 2013 12:20:26 -0800
Subject: [PATCH] Fix unhandled exception from attempting to access menu
 itemAtIndex:-1

---
 src/cocoa_menu_item.c | 14 +++++++++-----
 1 file 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];
+
 	}
     }
 
-- 
1.8.3.rc0