Changeset 11872


Ignore:
Timestamp:
Feb 11, 2011, 3:17:36 AM (11 years ago)
Author:
livings124
Message:

fix a crash with the URL window, and memory leak with the URL window, and update the "Open" button of the URL window when shown

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r11868 r11872  
    12321232- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
    12331233{
    1234     if (returnCode != 1)
    1235         return;
    1236    
    1237     [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
     1234    if (returnCode == 1)
     1235        [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
     1236   
    12381237    [controller release];
    12391238}
  • trunk/macosx/URLSheetWindowController.m

    r11871 r11872  
    2626#import "Controller.h"
    2727
     28@interface URLSheetWindowController (Private)
     29
     30- (BOOL) updateOpenButtonForURL: (NSString *) string;
     31
     32@end
     33
    2834@implementation URLSheetWindowController
    2935
    30 NSString * urlString = @"";
     36NSString * urlString = nil;
    3137
    3238- (id) initWithController: (Controller *) controller
     
    4349    [fLabelField setStringValue: NSLocalizedString(@"Internet address of torrent file:", "URL sheet label")];
    4450   
    45     [fTextField setStringValue: urlString];
    46     [fTextField selectText: self];
     51    if (urlString)
     52    {
     53        [fTextField setStringValue: urlString];
     54        [fTextField selectText: self];
     55       
     56        [self updateOpenButtonForURL: urlString];
     57    }
    4758   
    4859    [fOpenButton setTitle: NSLocalizedString(@"Open", "URL sheet button")];
     
    5768    NSRect cancelFrame = [fCancelButton frame];
    5869    cancelFrame.size.width += 10.0;
    59    
    60    
    6170   
    6271    if (NSWidth(openFrame) > NSWidth(cancelFrame))
     
    93102- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
    94103{
    95     urlString = [fTextField stringValue];
     104    [urlString release];
     105    urlString = [[fTextField stringValue] retain];
    96106    [fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
    97107}
     
    99109- (void) controlTextDidChange: (NSNotification *) notification
    100110{
    101     NSString * string = [fTextField stringValue];
     111    [self updateOpenButtonForURL: [fTextField stringValue]];
     112}
     113
     114@end
     115
     116@implementation URLSheetWindowController (Private)
     117
     118- (BOOL) updateOpenButtonForURL: (NSString *) string
     119{
    102120    BOOL enable = YES;
    103121    if ([string isEqualToString: @""])
Note: See TracChangeset for help on using the changeset viewer.