From 3e916be78f3216dc22873994a155f937154c0c88 Mon Sep 17 00:00:00 2001 From: Steven Clark Date: Wed, 22 Oct 2014 21:55:29 -0400 Subject: [PATCH] Protect against empty context menus in edit task Protext against index out of bounds exceptions on empty context menus within the edit task and add task views --- View Controllers/TaskEditViewController.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/View Controllers/TaskEditViewController.m b/View Controllers/TaskEditViewController.m index 62aceed..f935fe8 100644 --- a/View Controllers/TaskEditViewController.m +++ b/View Controllers/TaskEditViewController.m @@ -412,8 +412,8 @@ - (void) priorityWasSelected:(NSInteger *)selectedIndex element:(id)element { - (void) projectWasSelected:(NSInteger *)selectedIndex element:(id)element { self.actionSheetPicker = nil; - if (selectedIndex >= 0) { - id taskBag = self.appDelegate.taskBag; + id taskBag = self.appDelegate.taskBag; + if (selectedIndex >= 0 && [[taskBag projects] count ] > 0) { NSString *item = [[taskBag projects] objectAtIndex:selectedIndex]; if (! [TaskUtil taskHasProject:self.textView.text project:item]) { @@ -429,8 +429,8 @@ - (void) projectWasSelected:(NSInteger *)selectedIndex element:(id)element { - (void) contextWasSelected:(NSInteger *)selectedIndex element:(id)element { self.actionSheetPicker = nil; - if (selectedIndex >= 0) { - id taskBag = self.appDelegate.taskBag; + id taskBag = self.appDelegate.taskBag; + if (selectedIndex >= 0 && [[taskBag contexts] count] > 0) { NSString *item = [[taskBag contexts] objectAtIndex:selectedIndex]; if (! [TaskUtil taskHasContext:self.textView.text context:item]) {