get rid of a crash when canceling the open sheet

This commit is contained in:
Mitchell Livingston 2008-01-05 21:31:05 +00:00
parent 3cfbb199af
commit 57bc23edc5
5 changed files with 31 additions and 18 deletions

View File

@ -48,6 +48,8 @@
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller
deleteTorrent: (torrentFileState) deleteTorrent;
- (Torrent *) torrent;
- (void) setDestination: (id) sender;
- (void) add: (id) sender;

View File

@ -124,6 +124,11 @@
[super dealloc];
}
- (Torrent *) torrent
{
return fTorrent;
}
- (void) setDestination: (id) sender
{
NSOpenPanel * panel = [NSOpenPanel openPanel];
@ -146,20 +151,15 @@
[fTorrent setWaitToStart: [fStartCheck state] == NSOnState];
[fTorrent setGroupValue: [[fGroupPopUp selectedItem] tag]];
[fController askOpenConfirmed: fTorrent];
[fController askOpenConfirmed: self add: YES];
if ([fDeleteCheck state] == NSOnState)
[fTorrent trashTorrent];
[self release];
}
- (void) cancelAdd: (id) sender
{
[fTorrent closeRemoveTorrent];
[fTorrent release];
[self release];
[fController askOpenConfirmed: self add: NO];
}
- (void) updateGroupMenu: (NSNotification *) notification
@ -200,9 +200,8 @@
}
else
{
#warning crashes here
if (!fDestination)
[self cancelAdd: nil];
[self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
}
}

View File

@ -27,6 +27,7 @@
#import "PrefsController.h"
#import "InfoWindowController.h"
#import "MessageWindowController.h"
#import "AddWindowController.h"
#import "DragOverlayWindow.h"
#import "Badger.h"
#import "StatusBarView.h"
@ -118,7 +119,7 @@ typedef enum
- (void) openFiles: (NSArray *) filenames;
- (void) openFiles: (NSArray *) filenames addType: (addType) type forcePath: (NSString *) path;
- (void) askOpenConfirmed: (Torrent *) torrent;
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add;
- (void) openCreatedFile: (NSNotification *) notification;
- (void) openFilesWithDict: (NSDictionary *) dictionary;
- (void) openShowSheet: (id) sender;

View File

@ -30,7 +30,6 @@
#import "TorrentTableView.h"
#import "CreatorWindowController.h"
#import "StatsWindowController.h"
#import "AddWindowController.h"
#import "GroupsWindowController.h"
#import "AboutWindowController.h"
#import "ButtonToolbarItem.h"
@ -797,15 +796,28 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[self updateTorrentsInQueue];
}
- (void) askOpenConfirmed: (Torrent *) torrent
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
{
[torrent setOrderValue: [fTorrents count]-1]; //ensure that queue order is always sequential
[addController close];
[torrent update];
[fTorrents addObject: torrent];
[torrent release];
Torrent * torrent = [addController torrent];
if (add)
{
[torrent setOrderValue: [fTorrents count]-1]; //ensure that queue order is always sequential
[torrent update];
[fTorrents addObject: torrent];
[torrent release];
[self updateTorrentsInQueue];
}
else
{
[torrent closeRemoveTorrent];
[torrent release];
}
[self updateTorrentsInQueue];
[addController release];
}
- (void) openCreatedFile: (NSNotification *) notification

View File

@ -1485,7 +1485,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
if (fPublicTorrent)
fPublicTorrentLocation = [path retain];
#warning can it be nil? -- doesn't need the default value, since it'll be passed in
fDownloadFolder = downloadFolder ? downloadFolder : [fDefaults stringForKey: @"DownloadFolder"];
fDownloadFolder = [[fDownloadFolder stringByExpandingTildeInPath] retain];