chat: fix crash when file transfer was aborted due to some error in liblinphone

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-02 14:34:46 +02:00
parent d55cc1b93a
commit 980811a75c
2 changed files with 8 additions and 7 deletions

View file

@ -137,19 +137,20 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
}
- (void)upload:(UIImage *)image withURL:(NSURL *)url forChatRoom:(LinphoneChatRoom *)chatRoom {
[[[LinphoneManager instance] fileTransferDelegates] addObject:self];
[LinphoneManager.instance.fileTransferDelegates addObject:self];
LinphoneContent *content = linphone_core_create_content(linphone_chat_room_get_lc(chatRoom));
_data = [NSMutableData dataWithData:UIImageJPEGRepresentation(image, 1.0)];
linphone_content_set_type(content, "image");
linphone_content_set_subtype(content, "jpeg");
linphone_content_set_name(content,
[[NSString stringWithFormat:@"%li-%f.jpg", (long)[image hash],
[[NSString stringWithFormat:@"%li-%f.jpg", (long)image.hash,
[NSDate timeIntervalSinceReferenceDate]] UTF8String]);
linphone_content_set_size(content, [_data length]);
linphone_content_set_size(content, _data.length);
_message = linphone_chat_room_create_file_transfer_message(chatRoom, content);
linphone_chat_message_ref(_message);
linphone_content_unref(content);
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message),
linphone_iphone_file_transfer_send);
@ -158,7 +159,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
[LinphoneManager setValueInMessageAppData:[url absoluteString] forKey:@"localimage" inMessage:_message];
}
LOGI(@"%p Uploading content in %p", self, _message);
LOGI(@"%p Uploading content from message %p", self, _message);
linphone_chat_room_send_chat_message(chatRoom, _message);
}
@ -193,7 +194,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
linphone_chat_message_cancel_file_transfer(_message);
linphone_chat_message_unref(_message);
}
_message = nil;
_message = NULL;
_data = nil;
LOGI(@"%p Destroying", self);
}

@ -1 +1 @@
Subproject commit a722c765153c7f0065ccca1137c7b4d97294477f
Subproject commit 434907917e933737b31b93853019f3a8c7300675