mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
Prevent crash in message tests.
This commit is contained in:
parent
db52ddaa09
commit
03130daadc
4 changed files with 17 additions and 12 deletions
|
|
@ -117,13 +117,14 @@ void linphone_chat_message_cbs_set_file_transfer_progress_indication(
|
|||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatMessage);
|
||||
|
||||
static void _linphone_chat_room_destroy(LinphoneChatRoom *cr) {
|
||||
bctbx_list_free_with_data(cr->transient_messages, (void (*)(void *))linphone_chat_message_release);
|
||||
if (cr->received_rtt_characters) {
|
||||
cr->received_rtt_characters = bctbx_list_free_with_data(cr->received_rtt_characters, (void (*)(void *))ms_free);
|
||||
}
|
||||
linphone_chat_room_delete_composing_idle_timer(cr);
|
||||
linphone_chat_room_delete_composing_refresh_timer(cr);
|
||||
linphone_chat_room_delete_remote_composing_refresh_timer(cr);
|
||||
bctbx_list_free_with_data(cr->transient_messages, (bctbx_list_free_func)linphone_chat_message_release);
|
||||
if (cr->weak_messages != NULL) bctbx_list_free(cr->weak_messages);
|
||||
if (cr->received_rtt_characters) {
|
||||
cr->received_rtt_characters = bctbx_list_free_with_data(cr->received_rtt_characters, (bctbx_list_free_func)ms_free);
|
||||
}
|
||||
if (cr->lc != NULL) {
|
||||
if (bctbx_list_find(cr->lc->chatrooms, cr)) {
|
||||
ms_error("LinphoneChatRoom[%p] is destroyed while still being used by the LinphoneCore. This is abnormal."
|
||||
|
|
@ -138,7 +139,6 @@ static void _linphone_chat_room_destroy(LinphoneChatRoom *cr) {
|
|||
if (cr->pending_message)
|
||||
linphone_chat_message_destroy(cr->pending_message);
|
||||
ms_free(cr->peer);
|
||||
if (cr->weak_messages != NULL) bctbx_list_free(cr->weak_messages);
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
|
||||
|
|
@ -313,6 +313,7 @@ void linphone_chat_room_release(LinphoneChatRoom *cr) {
|
|||
linphone_chat_room_delete_composing_refresh_timer(cr);
|
||||
linphone_chat_room_delete_remote_composing_refresh_timer(cr);
|
||||
bctbx_list_for_each(cr->weak_messages, (bctbx_list_iterate_func)linphone_chat_message_deactivate);
|
||||
bctbx_list_for_each(cr->transient_messages, (bctbx_list_iterate_func)linphone_chat_message_deactivate);
|
||||
cr->lc = NULL;
|
||||
linphone_chat_room_unref(cr);
|
||||
}
|
||||
|
|
@ -1717,11 +1718,11 @@ void linphone_chat_message_unref(LinphoneChatMessage *msg) {
|
|||
}
|
||||
|
||||
static void linphone_chat_message_deactivate(LinphoneChatMessage *msg){
|
||||
if (msg->file_transfer_information != NULL) {
|
||||
_linphone_chat_message_cancel_file_transfer(msg, FALSE);
|
||||
}
|
||||
/*mark the chat msg as orphan (it has no chat room anymore)*/
|
||||
msg->chat_room = NULL;
|
||||
if (msg->file_transfer_information != NULL) {
|
||||
linphone_chat_message_cancel_file_transfer(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void linphone_chat_message_release(LinphoneChatMessage *msg) {
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ void linphone_chat_message_start_file_download(LinphoneChatMessage *msg,
|
|||
linphone_chat_message_download_file(msg);
|
||||
}
|
||||
|
||||
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
|
||||
void _linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg, bool_t unref) {
|
||||
if (msg->http_request) {
|
||||
if (msg->state == LinphoneChatMessageStateInProgress) {
|
||||
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
|
||||
|
|
@ -625,7 +625,7 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
|
|||
, msg
|
||||
, msg->chat_room);
|
||||
belle_http_provider_cancel_request(msg->chat_room->lc->http_provider, msg->http_request);
|
||||
if (msg->dir == LinphoneChatMessageOutgoing) {
|
||||
if ((msg->dir == LinphoneChatMessageOutgoing) && unref) {
|
||||
// must release it
|
||||
linphone_chat_message_unref(msg);
|
||||
}
|
||||
|
|
@ -639,6 +639,10 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
|
|||
}
|
||||
}
|
||||
|
||||
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
|
||||
_linphone_chat_message_cancel_file_transfer(msg, TRUE);
|
||||
}
|
||||
|
||||
void linphone_chat_message_set_file_transfer_filepath(LinphoneChatMessage *msg, const char *filepath) {
|
||||
if (msg->file_transfer_filepath != NULL) {
|
||||
ms_free(msg->file_transfer_filepath);
|
||||
|
|
|
|||
|
|
@ -657,6 +657,7 @@ void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessa
|
|||
void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured);
|
||||
void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *cm, LinphoneReason reason);
|
||||
void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm);
|
||||
void _linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg, bool_t unref);
|
||||
int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
|
||||
void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
|
||||
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
|
||||
|
|
|
|||
|
|
@ -1793,9 +1793,8 @@ void file_transfer_io_error_base(char *server_url, bool_t destroy_room) {
|
|||
linphone_chat_room_send_chat_message(chatroom, msg);
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageInProgress, 1, 1000));
|
||||
if (destroy_room) {
|
||||
//since message is orphan, we do not expect to be notified of state change
|
||||
linphone_core_delete_chat_room(marie->lc, chatroom);
|
||||
BC_ASSERT_FALSE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000));
|
||||
} else {
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 3000));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue