#3686 "add rpc command to cleanly shutdown daemon" - added for Mac client
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 15 Jan 2011 18:44:39 +0000 (18:44 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 15 Jan 2011 18:44:39 +0000 (18:44 +0000)
macosx/Controller.h
macosx/Controller.m

index 0f1182fbdd3dd8167b389e8888bf9e5cdde71330..b14d2f883e8fa71f259b34a7c0be29471b5e10a2 100644 (file)
@@ -103,8 +103,7 @@ typedef enum
     #warning change to QLPreviewPanel
     id                              fPreviewPanel;
     BOOL                            fQuitting;
-    
-    BOOL                            fUpdateInProgress;
+    BOOL                            fQuitRequested;
     BOOL                            fPauseOnLaunch;
     
     Badger                          * fBadger;
index 82d112370ad4b27f145b7d4f44077ff7e9b95553..b522538c2a6cfd7196638ea5c8ada4515e4c0fff 100644 (file)
@@ -390,7 +390,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [[UKKQueue sharedFileWatcher] setDelegate: self];
         
         [[SUUpdater sharedUpdater] setDelegate: self];
-        fUpdateInProgress = NO;
+        fQuitRequested = NO;
         
         fPauseOnLaunch = (GetCurrentKeyModifiers() & (optionKey | rightOptionKey)) != 0;
     }
@@ -677,7 +677,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) sender
 {
-    if (!fUpdateInProgress && [fDefaults boolForKey: @"CheckQuit"])
+    if (!fQuitRequested && [fDefaults boolForKey: @"CheckQuit"])
     {
         NSInteger active = 0, downloading = 0;
         for (Torrent * torrent  in fTorrents)
@@ -4358,7 +4358,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) updaterWillRelaunchApplication: (SUUpdater *) updater
 {
-    fUpdateInProgress = YES;
+    fQuitRequested = YES;
 }
 
 - (NSDictionary *) registrationDictionaryForGrowl
@@ -4440,6 +4440,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             [fPrefsController performSelectorOnMainThread: @selector(rpcUpdatePrefs) withObject: nil waitUntilDone: NO];
             break;
         
+        case TR_RPC_SESSION_CLOSE:
+            fQuitRequested = YES;
+            [NSApp performSelectorOnMainThread: @selector(terminate:) withObject: self waitUntilDone: NO];
+            break;
+        
         default:
             NSAssert1(NO, @"Unknown RPC command received: %d", type);
             [torrent release];