mirror of
https://github.com/transmission/transmission.git
synced 2025-12-26 05:08:32 +00:00
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
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,15 @@
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user