Changeset 4793

Show
Ignore:
Timestamp:
05/27/07 14:57:16 (2 years ago)
Author:
morris
Message:

Fix exceptions when events sound menu is empty or unselected

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCApplicationController.m

    r4792 r4793  
    474474- (void)serverConnectionTriggeredEvent:(NSNotification *)notification { 
    475475        NSDictionary            *event; 
     476        NSString                        *sound; 
     477        NSNumber                        *clickContext; 
    476478        WCServerConnection      *connection; 
    477         NSNumber                        *clickContext; 
    478479        id                                      info1, info2; 
    479480         
     
    483484        info2 = [[notification userInfo] objectForKey:WCServerConnectionEventInfo2Key]; 
    484485         
    485         if([event boolForKey:WCEventsPlaySound]) 
    486                 [NSSound playSoundNamed:[event objectForKey:WCEventsSound]]; 
     486        if([event boolForKey:WCEventsPlaySound]) { 
     487                sound = [event objectForKey:WCEventsSound]; 
     488                 
     489                if(sound) 
     490                        [NSSound playSoundNamed:sound]; 
     491        } 
    487492            
    488493        if([event boolForKey:WCEventsBounceInDock]) 
  • WiredClient/trunk/WCPreferences.m

    r4789 r4793  
    547547        [event setInt:tag forKey:WCEventsEvent]; 
    548548        [event setBool:[_playSoundButton state] forKey:WCEventsPlaySound]; 
    549         [event setObject:[_soundsPopUpButton titleOfSelectedItem] forKey:WCEventsSound]; 
     549         
     550        string = [_soundsPopUpButton titleOfSelectedItem]; 
     551         
     552        if(string) 
     553                [event setObject:string forKey:WCEventsSound]; 
     554         
    550555        [event setBool:[_bounceInDockButton state] forKey:WCEventsBounceInDock]; 
    551556        [event setBool:[_postInChatButton state] forKey:WCEventsPostInChat]; 
     
    675680- (void)_selectEvent { 
    676681        NSDictionary    *event; 
     682        NSString                *sound; 
    677683        int                             tag; 
    678684        BOOL                    on; 
     
    682688        [_playSoundButton setState:[event boolForKey:WCEventsPlaySound]]; 
    683689         
    684         if([(NSString *) [event objectForKey:WCEventsSound] length] > 0) 
    685                 [_soundsPopUpButton selectItemWithTitle:[event objectForKey:WCEventsSound]]; 
     690        sound = [event objectForKey:WCEventsSound]; 
     691         
     692        if(sound && [_soundsPopUpButton indexOfItemWithTitle:sound] != -1) 
     693                [_soundsPopUpButton selectItemWithTitle:sound]; 
     694        else if ([_soundsPopUpButton numberOfItems] > 0) 
     695                [_soundsPopUpButton selectItemAtIndex:0]; 
    686696 
    687697        [_bounceInDockButton setState:[event boolForKey:WCEventsBounceInDock]]; 
     
    11511161 
    11521162- (IBAction)touchEvent:(id)sender { 
     1163        NSString        *sound; 
     1164         
    11531165        [self _touchEvents]; 
    11541166         
    1155         if(sender == _playSoundButton && [_playSoundButton state]) 
    1156                 [NSSound playSoundNamed:[_soundsPopUpButton titleOfSelectedItem]]; 
     1167        if(sender == _playSoundButton && [_playSoundButton state]) { 
     1168                sound = [_soundsPopUpButton titleOfSelectedItem]; 
     1169                 
     1170                if(sound) 
     1171                        [NSSound playSoundNamed:sound]; 
     1172        } 
    11571173         
    11581174        [self _saveSettings]; 
     
    11621178 
    11631179- (IBAction)selectSound:(id)sender { 
    1164         [NSSound playSoundNamed:[_soundsPopUpButton titleOfSelectedItem]]; 
     1180        NSString        *sound; 
     1181         
     1182        sound = [_soundsPopUpButton titleOfSelectedItem]; 
     1183 
     1184        if(sound) 
     1185                [NSSound playSoundNamed:sound]; 
    11651186         
    11661187        [self _saveSettings];