mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 21:28:08 +00:00
Fix wrong handling of MessageOp in ChatMessage (it needs to be able to survive to the destruction of the ChatMessage).
This commit is contained in:
parent
b0315c1570
commit
e415dbacb9
2 changed files with 12 additions and 13 deletions
|
|
@ -555,17 +555,14 @@ static LinphoneChatMessageState chatStatusSal2Linphone(SalMessageDeliveryStatus
|
|||
return LinphoneChatMessageStateIdle;
|
||||
}
|
||||
|
||||
static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status){
|
||||
LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )op->get_user_pointer();
|
||||
static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status) {
|
||||
LinphonePrivate::ChatMessage *msg = reinterpret_cast<LinphonePrivate::ChatMessage *>(op->get_user_pointer());
|
||||
if (!msg)
|
||||
return; // Do not handle delivery status for isComposing messages.
|
||||
|
||||
if (chat_msg == NULL) {
|
||||
// Do not handle delivery status for isComposing messages.
|
||||
return;
|
||||
}
|
||||
// check that the message does not belong to an already destroyed chat room - if so, do not invoke callbacks
|
||||
if (linphone_chat_message_get_chat_room(chat_msg) != NULL) {
|
||||
linphone_chat_message_update_state(chat_msg, chatStatusSal2Linphone(status));
|
||||
}
|
||||
// Check that the message does not belong to an already destroyed chat room - if so, do not invoke callbacks
|
||||
if (msg->getChatRoom())
|
||||
msg->updateState((LinphonePrivate::ChatMessage::State)chatStatusSal2Linphone(status));
|
||||
}
|
||||
|
||||
static void info_received(SalOp *op, SalBodyHandler *body_handler) {
|
||||
|
|
|
|||
|
|
@ -543,7 +543,7 @@ void ChatMessagePrivate::send () {
|
|||
core->getCCore(), op, peer, getSalCustomHeaders(),
|
||||
!!lp_config_get_int(core->getCCore()->config, "sip", "chat_msg_with_contact", 0)
|
||||
);
|
||||
op->set_user_pointer(L_GET_C_BACK_PTR(q)); /* If out of call, directly store msg */
|
||||
op->set_user_pointer(q); /* If out of call, directly store msg */
|
||||
linphone_address_unref(peer);
|
||||
}
|
||||
op->set_from(q->getFromAddress().asString().c_str());
|
||||
|
|
@ -712,8 +712,10 @@ ChatMessage::~ChatMessage () {
|
|||
for (Content *content : d->contents)
|
||||
delete content;
|
||||
|
||||
if (d->salOp)
|
||||
d->salOp->release();
|
||||
if (d->salOp) {
|
||||
d->salOp->set_user_pointer(nullptr);
|
||||
d->salOp->unref();
|
||||
}
|
||||
if (d->salCustomHeaders)
|
||||
sal_custom_header_unref(d->salCustomHeaders);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue