Merge lp:~mikemc/ubuntuone-ios-music/showing-settingsviewcontroller into lp:ubuntuone-ios-music

Proposed by Mike McCracken
Status: Merged
Approved by: Paul Hummer
Approved revision: 258
Merged at revision: 258
Proposed branch: lp:~mikemc/ubuntuone-ios-music/showing-settingsviewcontroller
Merge into: lp:ubuntuone-ios-music
Diff against target: 28 lines (+10/-1)
1 file modified
Music/UOAppDelegate.m (+10/-1)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-ios-music/showing-settingsviewcontroller
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+153630@code.launchpad.net

Commit message

- Fix fencepost error in showing settings view when no creds are found.

Description of the change

- Fix fencepost error in showing settings view when no creds are found.

The issue was caused by the activate code assuming there would be 5 tab view controllers, when there was only 4, due to disabling the connection to the playlistslistviewcontroller in the storyboard.

The crash was apparently due to trying to activate a songs view controller when it was expecting creds. It was activating an arbitrary one because there were 4 view controllers and we were telling it to activate the one at index 4.

I was able to reproduce this on the iphone 6.1 simulator consistently, and this patch fixes the crash I was seeing.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Music/UOAppDelegate.m'
2--- Music/UOAppDelegate.m 2013-02-13 18:33:19 +0000
3+++ Music/UOAppDelegate.m 2013-03-15 21:28:21 +0000
4@@ -28,6 +28,7 @@
5 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
6 // DAMAGE.
7
8+#import "SettingsViewController.h"
9 #import "UOAppDelegate.h"
10 #import "UOAuthManager.h"
11 #import "U1LocalMusicServer.h"
12@@ -238,7 +239,15 @@
13 - (void)checkAuthentication {
14 if (![[UOAuthManager sharedAuthManager] hasCredentials]) {
15 UITabBarController *rootViewController = (UITabBarController *)self.window.rootViewController;
16- rootViewController.selectedIndex = 4;
17+
18+ NSArray *vcs = [rootViewController viewControllers];
19+ NSUInteger settings_idx = [vcs indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
20+ return [obj isKindOfClass:[SettingsViewController class]];
21+ }];
22+
23+ SettingsViewController *svc = [vcs objectAtIndex:settings_idx];
24+
25+ rootViewController.selectedViewController = svc;
26 }
27
28 [self.window makeKeyAndVisible];

Subscribers

People subscribed via source and target branches