Fixed the stupid crash on turning off network sharing.
[MenuTunes.git] / NetworkController.m
index 1d180c6..70994df 100755 (executable)
@@ -78,10 +78,10 @@ static NetworkController *sharedController;
             serverConnection = [[NSConnection alloc] initWithReceivePort:serverPort
                                                      sendPort:serverPort];
             clientProxy = [[NetworkObject alloc] init];
-            [serverConnection setRootObject:[clientProxy autorelease]];
+            [serverConnection setRootObject:clientProxy];
             [serverConnection registerName:@"ITMTPlayerHost"];
         NS_HANDLER
-            [[serverConnection rootObject] release];
+            [clientProxy release];
             [serverConnection setRootObject:nil];
             [serverConnection release];
             [serverPort release];
@@ -110,7 +110,9 @@ static NetworkController *sharedController;
     } else if (serverOn && !status && [serverConnection isValid]) {
         //Turn off
         [service stop];
+        [clientProxy invalidate];
         [serverConnection registerName:nil];
+        [serverConnection setRootObject:nil];
         [serverConnection release];
         ITDebugLog(@"Stopped server.");
         serverOn = NO;