Fixed menu reordering crashing in preferences thingy yay.
[MenuTunes.git] / PreferencesController.m
index e1c47d1..4ad0f4f 100755 (executable)
@@ -208,8 +208,8 @@ static PreferencesController *prefs = nil;
 
     [df setObject:[NSArray arrayWithObjects:
         @"playPause",
 
     [df setObject:[NSArray arrayWithObjects:
         @"playPause",
-        @"nextTrack",
         @"prevTrack",
         @"prevTrack",
+        @"nextTrack",
         @"fastForward",
         @"rewind",
         @"showPlayer",
         @"fastForward",
         @"rewind",
         @"showPlayer",
@@ -762,17 +762,17 @@ static PreferencesController *prefs = nil;
         dragData = [pb stringForType:@"MenuTableViewPboardType"];
         dragRow = [dragData intValue];
         temp = [myItems objectAtIndex:dragRow];
         dragData = [pb stringForType:@"MenuTableViewPboardType"];
         dragRow = [dragData intValue];
         temp = [myItems objectAtIndex:dragRow];
-        [myItems removeObjectAtIndex:dragRow];
-        
         if (tableView == menuTableView) {
         if (tableView == menuTableView) {
+            [myItems insertObject:temp atIndex:row];
             if (row > dragRow) {
             if (row > dragRow) {
-                [myItems insertObject:temp atIndex:row - 1];
+                [myItems removeObjectAtIndex:dragRow];
             } else {
             } else {
-                [myItems insertObject:temp atIndex:row];
+                [myItems removeObjectAtIndex:dragRow + 1];
             }
         } else {
             if (![temp isEqualToString:@"separator"]) {
                 [availableItems addObject:temp];
             }
         } else {
             if (![temp isEqualToString:@"separator"]) {
                 [availableItems addObject:temp];
+                [myItems removeObjectAtIndex:dragRow];
             }
         }
     } else if ([[pb types] containsObject:@"AllTableViewPboardType"]) {
             }
         }
     } else if ([[pb types] containsObject:@"AllTableViewPboardType"]) {
@@ -780,10 +780,11 @@ static PreferencesController *prefs = nil;
         dragRow = [dragData intValue];
         temp = [availableItems objectAtIndex:dragRow];
         
         dragRow = [dragData intValue];
         temp = [availableItems objectAtIndex:dragRow];
         
+        [myItems insertObject:temp atIndex:row];
+        
         if (![temp isEqualToString:@"separator"]) {
             [availableItems removeObjectAtIndex:dragRow];
         }
         if (![temp isEqualToString:@"separator"]) {
             [availableItems removeObjectAtIndex:dragRow];
         }
-        [myItems insertObject:temp atIndex:row];
     }
     
     [menuTableView reloadData];
     }
     
     [menuTableView reloadData];