From 7acd8fff2624c3941ff5c7ec92c8b5f48bdf369a Mon Sep 17 00:00:00 2001 From: Frederic Jacobs Date: Fri, 19 Jun 2015 14:00:49 +0200 Subject: [PATCH] Fixing memory issue with allocation of the socket status view. --- .../view controllers/SignalsNavigationController.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Signal/src/view controllers/SignalsNavigationController.m b/Signal/src/view controllers/SignalsNavigationController.m index 488c6707a..a11cef458 100644 --- a/Signal/src/view controllers/SignalsNavigationController.m +++ b/Signal/src/view controllers/SignalsNavigationController.m @@ -32,20 +32,23 @@ static double const STALLED_PROGRESS = 0.9; -(void)initializeSocketStatusBar { - _socketStatusView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault]; + if (!_socketStatusView) { + _socketStatusView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault]; + } CGRect bar = self.navigationBar.frame; _socketStatusView.frame = CGRectMake(0, bar.size.height-1.0f, self.view.frame.size.width, 1.0f); _socketStatusView.progress = 0.0f; _socketStatusView.progressTintColor = [UIColor ows_fadedBlueColor]; - [self.navigationBar addSubview:_socketStatusView]; + + if (![_socketStatusView superview]) { + [self.navigationBar addSubview:_socketStatusView]; + } } -(void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self name:SocketOpenedNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:SocketClosedNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:SocketConnectingNotification object:nil]; +[[NSNotificationCenter defaultCenter] removeObserver:self]; } #pragma mark - Socket Status Notifications