Sfoglia il codice sorgente

Fix a crash in the Local Network view controller

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Marc Etcheverry 11 anni fa
parent
commit
ad70002aed
1 ha cambiato i file con 32 aggiunte e 0 eliminazioni
  1. 32 0
      Sources/VLCLocalServerListViewController.m

+ 32 - 0
Sources/VLCLocalServerListViewController.m

@@ -61,6 +61,14 @@
 
 - (void)dealloc
 {
+    [[NSNotificationCenter defaultCenter] removeObserver:self
+                                                    name:UIApplicationWillResignActiveNotification
+                                                  object:[UIApplication sharedApplication]];
+
+    [[NSNotificationCenter defaultCenter] removeObserver:self
+                                                    name:UIApplicationDidBecomeActiveNotification
+                                                  object:[UIApplication sharedApplication]];
+
     [_reachability stopNotifier];
     [_ftpNetServiceBrowser stop];
     [_PlexNetServiceBrowser stop];
@@ -82,10 +90,34 @@
     [self.view addSubview:_activityIndicator];
 }
 
+- (void)applicationWillResignActive:(NSNotification *)notification
+{
+    [self _stopUPNPDiscovery];
+    [self _stopSAPDiscovery];
+}
+
+- (void)applicationDidBecomeActive:(NSNotification *)notification
+{
+    if (_reachability.currentReachabilityStatus == ReachableViaWiFi) {
+        [self performSelectorInBackground:@selector(_startUPNPDiscovery) withObject:nil];
+        [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
+    }
+}
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];
 
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(applicationWillResignActive:)
+                                                 name:UIApplicationWillResignActiveNotification
+                                               object:[UIApplication sharedApplication]];
+
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(applicationDidBecomeActive:)
+                                                 name:UIApplicationDidBecomeActiveNotification
+                                               object:[UIApplication sharedApplication]];
+
 /*    if (SYSTEM_RUNS_IOS7_OR_LATER)
         _sectionHeaderTexts = @[@"Universal Plug'n'Play (UPNP)", @"File Transfer Protocol (FTP)", @"Network Streams (SAP)"];
     else*/