Cope with invalid keyboard ids

This commit is contained in:
nigel 2003-08-16 11:16:36 +00:00
parent 14a5fd6aaf
commit 415c2721bc

View File

@ -298,10 +298,8 @@ extern string UserPrefsPath; // from prefs_unix.cpp
- (IBAction) ChangeKeyboard: (NSPopUpButton *)sender - (IBAction) ChangeKeyboard: (NSPopUpButton *)sender
{ {
// Deselest current item // Deselest current item
int val = PrefsFindInt32("keyboardtype"); int current = [keyboard indexOfItemWithTag: PrefsFindInt32("keyboardtype")];
int current = [keyboard indexOfItemWithTag: val]; if ( current != -1 )
if ( current )
[[keyboard itemAtIndex: current] setState: FALSE]; [[keyboard itemAtIndex: current] setState: FALSE];
PrefsReplaceInt32("keyboardtype", [[sender selectedItem] tag]); PrefsReplaceInt32("keyboardtype", [[sender selectedItem] tag]);
@ -774,7 +772,9 @@ shouldProceedAfterError: (NSDictionary *) errorDict
// Lists of thingies: // Lists of thingies:
val = PrefsFindInt32("keyboardtype"); val = PrefsFindInt32("keyboardtype");
[keyboard selectItemAtIndex: [keyboard indexOfItemWithTag: val]]; tmp = [keyboard indexOfItemWithTag: val];
if ( tmp != -1 )
[keyboard selectItemAtIndex: tmp];
for ( tmp = 0; tmp < [keyboard numberOfItems]; ++tmp ) for ( tmp = 0; tmp < [keyboard numberOfItems]; ++tmp )
{ {
NSMenuItem *type = [keyboard itemAtIndex: tmp]; NSMenuItem *type = [keyboard itemAtIndex: tmp];