]> granicus.if.org Git - transmission/commitdiff
fix a crash with the URL window, and memory leak with the URL window, and update...
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 11 Feb 2011 03:17:36 +0000 (03:17 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 11 Feb 2011 03:17:36 +0000 (03:17 +0000)
macosx/Controller.m
macosx/URLSheetWindowController.m

index 3e1eb7ca5e08dccb1b324fbbeaa220ae91773984..9b72d4c036ae53a919bafeeef0d161b34049df3a 100644 (file)
@@ -1231,10 +1231,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
 {
-    if (returnCode != 1)
-        return;
+    if (returnCode == 1)
+        [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
     
-    [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
     [controller release];
 }
 
index 7714f674e878ec71c973d30dc59139ed9bdb5e1b..696fef3ef639225e01d45d9cdc5e0f96f0241924 100644 (file)
 #import "URLSheetWindowController.h"
 #import "Controller.h"
 
+@interface URLSheetWindowController (Private)
+
+- (BOOL) updateOpenButtonForURL: (NSString *) string;
+
+@end
+
 @implementation URLSheetWindowController
 
-NSString * urlString = @"";
+NSString * urlString = nil;
 
 - (id) initWithController: (Controller *) controller
 {
@@ -42,8 +48,13 @@ NSString * urlString = @"";
 {
     [fLabelField setStringValue: NSLocalizedString(@"Internet address of torrent file:", "URL sheet label")];
     
-    [fTextField setStringValue: urlString];
-    [fTextField selectText: self];
+    if (urlString)
+    {
+        [fTextField setStringValue: urlString];
+        [fTextField selectText: self];
+        
+        [self updateOpenButtonForURL: urlString];
+    }
     
     [fOpenButton setTitle: NSLocalizedString(@"Open", "URL sheet button")];
     [fCancelButton setTitle: NSLocalizedString(@"Cancel", "URL sheet button")];
@@ -57,8 +68,6 @@ NSString * urlString = @"";
     NSRect cancelFrame = [fCancelButton frame];
     cancelFrame.size.width += 10.0;
     
-    
-    
     if (NSWidth(openFrame) > NSWidth(cancelFrame))
         cancelFrame.size.width = NSWidth(openFrame);
     else
@@ -92,13 +101,22 @@ NSString * urlString = @"";
 
 - (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
 {
-    urlString = [fTextField stringValue];
+    [urlString release];
+    urlString = [[fTextField stringValue] retain];
     [fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
 }
 
 - (void) controlTextDidChange: (NSNotification *) notification
 {
-    NSString * string = [fTextField stringValue];
+    [self updateOpenButtonForURL: [fTextField stringValue]];
+}
+
+@end
+
+@implementation URLSheetWindowController (Private)
+
+- (BOOL) updateOpenButtonForURL: (NSString *) string
+{
     BOOL enable = YES;
     if ([string isEqualToString: @""])
         enable = NO;