Fix crash onPresenceChanged

This commit is contained in:
Benjamin Reis 2016-12-23 10:56:55 +01:00
parent d96fef0fc0
commit d7d3c509b8
4 changed files with 8 additions and 4 deletions

View file

@ -186,7 +186,7 @@
_editButton.hidden = TRUE;
_deleteButton.hidden = TRUE;
}
PhoneMainView.instance.currentName = _nameLabel.text;
// Update presence for contact
for (NSInteger j = 0; j < [self.tableController.tableView numberOfSections]; ++j) {
for (NSInteger i = 0; i < [self.tableController.tableView numberOfRowsInSection:j]; ++i) {
@ -222,6 +222,7 @@
- (void)viewWillDisappear:(BOOL)animated {
[_tableController.tableView removeObserver:self forKeyPath:@"contentSize"];
[super viewWillDisappear:animated];
PhoneMainView.instance.currentName = NULL;
if (self.tmpContact) {
_contact.firstName = _tmpContact.firstName.copy;
_contact.lastName = _tmpContact.lastName.copy;

View file

@ -20,6 +20,7 @@
#import "UIContactCell.h"
#import "ContactsListTableView.h"
#import "FastAddressBook.h"
#import "PhoneMainView.h"
#import "UILabel+Boldify.h"
#import "Utils.h"
@ -37,7 +38,7 @@
UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:0]);
[self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)];
[self addSubview:sub];
_contact = NULL;
// Sections are wider on iPad and overlap linphone image - let's move it a bit
if (IPAD) {
CGRect frame = _linphoneImage.frame;
@ -63,12 +64,12 @@
- (void)onPresenceChanged:(NSNotification *)k {
LinphoneFriend *f = [[k.userInfo valueForKey:@"friend"] pointerValue];
// only consider event if it's about us
if (_contact) {
if (_contact && (_nameLabel.text == PhoneMainView.instance.currentName || !PhoneMainView.instance.currentName)) {
if (!_contact.friend || f != _contact.friend) {
return;
}
[self setContact:_contact];
}
[self setContact:_contact];
}
#pragma mark - Property Functions

View file

@ -78,6 +78,7 @@
@property(nonatomic, strong) IBOutlet UIView *statusBarBG;
@property(nonatomic, strong) IBOutlet UICompositeView *mainViewController;
@property(nonatomic, strong) NSString *currentName;
@property(nonatomic, strong) NSString *name;
@property(weak, readonly) UICompositeViewDescription *currentView;
@property LinphoneChatRoom* currentRoom;

View file

@ -127,6 +127,7 @@ static RootViewManager *rootViewManagerInstance = nil;
- (void)initPhoneMainView {
currentView = nil;
_currentRoom = NULL;
_currentName = NULL;
inhibitedEvents = [[NSMutableArray alloc] init];
}