--(IBAction) removePressed: (id)sender {
- // save changes first
- [tableView reloadData];
- Config* current_config = configs[[tableView selectedRow]];
- if([current_config protect])
- return;
- [configs removeObjectAtIndex: [tableView selectedRow]];
-
- // remove all "switch to configuration" actions
- for(int i=0; i<[configs count]; i++) {
- NSMutableDictionary* entries = [(Config*)configs[i] entries];
- for(id key in entries) {
- Target* target = (Target*) entries[key];
- if([target isKindOfClass: [TargetConfig class]] && [(TargetConfig*)target config] == current_config)
- [entries removeObjectForKey: key];
- }
- }
- [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
+
+- (IBAction)removePressed:(id)sender {
+ if (tableView.selectedRow == 0)
+ return;
+
+ Config *toRemove = configs[tableView.selectedRow];
+ [configs removeObjectAtIndex:tableView.selectedRow];
+
+ if (toRemove == currentConfig)
+ currentConfig = configs[0];
+ if (toRemove == manualConfig)
+ manualConfig = configs[0];