]> granicus.if.org Git - transmission/commitdiff
#948 - when processing the blocklist, don't block the gui (Leopard-only)
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 16 May 2008 00:25:09 +0000 (00:25 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 16 May 2008 00:25:09 +0000 (00:25 +0000)
macosx/BlocklistDownloader.m

index 0e1a93bd7453cc5c4ca5e38d2e2ecfcfe348e2b2..7d400b9c42bac99bb8884fb6c0b051796a1cb4b6 100644 (file)
@@ -34,6 +34,7 @@
 
 - (id) initWithPrefsController: (PrefsController *) prefsController;
 - (void) startDownload;
+- (void) finishDownloadSuccess;
 - (void) updateProcessString;
 - (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
 
 
 - (void) downloadDidFinish: (NSURLDownload *) download
 {
-    //change to indeterminate while processing
-    [fProgressBar setIndeterminate: YES];
-    [fProgressBar startAnimation: self];
-    
-    [fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
-    [fButton setEnabled: NO];
-    [fStatusWindow display]; //force window to be updated
-    
-    //process data
-    tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
-    
-    //delete downloaded file
     if ([NSApp isOnLeopardOrBetter])
-        [[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
+        [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
     else
-        [[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
-    
-    [fPrefsController updateBlocklistFields];
-    
-    [NSApp endSheet: fStatusWindow];
-    [fStatusWindow orderOut: self];
-    [self release];
+        [self finishDownloadSuccess];
 }
 
 @end
     [fDownload setDestination: DESTINATION allowOverwrite: YES];
 }
 
+- (void) finishDownloadSuccess
+{
+    //change to indeterminate while processing
+    [fProgressBar setIndeterminate: YES];
+    [fProgressBar startAnimation: self];
+    
+    [fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
+    [fButton setEnabled: NO];
+    [fStatusWindow display]; //force window to be updated
+    
+    //process data
+    tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
+    
+    //delete downloaded file
+    if ([NSApp isOnLeopardOrBetter])
+        [[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
+    else
+        [[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
+    
+    [fPrefsController updateBlocklistFields];
+    
+    [NSApp endSheet: fStatusWindow];
+    [fStatusWindow orderOut: self];
+    [self release];
+}
+
 - (void) updateProcessString
 {
     NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message");