Commit e415dbac authored by Ghislain MARY's avatar Ghislain MARY

Fix wrong handling of MessageOp in ChatMessage (it needs to be able to survive...

Fix wrong handling of MessageOp in ChatMessage (it needs to be able to survive to the destruction of the ChatMessage).
parent b0315c15
......@@ -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();
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));
}
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.
// 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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment