mirror of
https://github.com/transmission/transmission
synced 2025-02-28 00:35:31 +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:
parent
32a54d1029
commit
e5b8461919
2 changed files with 27 additions and 10 deletions
|
@ -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
|
- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
|
||||||
{
|
{
|
||||||
if (returnCode != 1)
|
if (returnCode == 1)
|
||||||
return;
|
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
|
||||||
|
|
||||||
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
|
|
||||||
[controller release];
|
[controller release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,15 @@
|
||||||
#import "URLSheetWindowController.h"
|
#import "URLSheetWindowController.h"
|
||||||
#import "Controller.h"
|
#import "Controller.h"
|
||||||
|
|
||||||
|
@interface URLSheetWindowController (Private)
|
||||||
|
|
||||||
|
- (BOOL) updateOpenButtonForURL: (NSString *) string;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation URLSheetWindowController
|
@implementation URLSheetWindowController
|
||||||
|
|
||||||
NSString * urlString = @"";
|
NSString * urlString = nil;
|
||||||
|
|
||||||
- (id) initWithController: (Controller *) controller
|
- (id) initWithController: (Controller *) controller
|
||||||
{
|
{
|
||||||
|
@ -42,8 +48,13 @@ NSString * urlString = @"";
|
||||||
{
|
{
|
||||||
[fLabelField setStringValue: NSLocalizedString(@"Internet address of torrent file:", "URL sheet label")];
|
[fLabelField setStringValue: NSLocalizedString(@"Internet address of torrent file:", "URL sheet label")];
|
||||||
|
|
||||||
[fTextField setStringValue: urlString];
|
if (urlString)
|
||||||
[fTextField selectText: self];
|
{
|
||||||
|
[fTextField setStringValue: urlString];
|
||||||
|
[fTextField selectText: self];
|
||||||
|
|
||||||
|
[self updateOpenButtonForURL: urlString];
|
||||||
|
}
|
||||||
|
|
||||||
[fOpenButton setTitle: NSLocalizedString(@"Open", "URL sheet button")];
|
[fOpenButton setTitle: NSLocalizedString(@"Open", "URL sheet button")];
|
||||||
[fCancelButton setTitle: NSLocalizedString(@"Cancel", "URL sheet button")];
|
[fCancelButton setTitle: NSLocalizedString(@"Cancel", "URL sheet button")];
|
||||||
|
@ -57,8 +68,6 @@ NSString * urlString = @"";
|
||||||
NSRect cancelFrame = [fCancelButton frame];
|
NSRect cancelFrame = [fCancelButton frame];
|
||||||
cancelFrame.size.width += 10.0;
|
cancelFrame.size.width += 10.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (NSWidth(openFrame) > NSWidth(cancelFrame))
|
if (NSWidth(openFrame) > NSWidth(cancelFrame))
|
||||||
cancelFrame.size.width = NSWidth(openFrame);
|
cancelFrame.size.width = NSWidth(openFrame);
|
||||||
else
|
else
|
||||||
|
@ -92,13 +101,22 @@ NSString * urlString = @"";
|
||||||
|
|
||||||
- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
- (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];
|
[fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) controlTextDidChange: (NSNotification *) notification
|
- (void) controlTextDidChange: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
NSString * string = [fTextField stringValue];
|
[self updateOpenButtonForURL: [fTextField stringValue]];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation URLSheetWindowController (Private)
|
||||||
|
|
||||||
|
- (BOOL) updateOpenButtonForURL: (NSString *) string
|
||||||
|
{
|
||||||
BOOL enable = YES;
|
BOOL enable = YES;
|
||||||
if ([string isEqualToString: @""])
|
if ([string isEqualToString: @""])
|
||||||
enable = NO;
|
enable = NO;
|
||||||
|
|
Loading…
Reference in a new issue