Commit 58e13184 authored by Simon Morlat's avatar Simon Morlat

fix crash in gtk chat

parent 846d2c57
......@@ -61,12 +61,17 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
GtkWidget *w=g_object_get_data(G_OBJECT(friendlist),"chatview");
gchar *from;
g_return_if_fail(w!=NULL);
gtk_notebook_remove_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),w));
linphone_gtk_friend_list_update_chat_picture();
g_object_set_data(G_OBJECT(friendlist),"chatview",NULL);
g_object_set_data(G_OBJECT(w),"from_message",NULL);
from=g_object_get_data(G_OBJECT(w),"from_message");
if (from){
g_object_set_data(G_OBJECT(w),"from_message",NULL);
g_free(from);
}
g_object_set_data(G_OBJECT(w),"cr",NULL);
g_object_set_data(G_OBJECT(friendlist),"from",NULL);
gtk_widget_destroy(w);
......@@ -128,7 +133,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
GtkTextIter iter,begin;
int off;
char *from_str=linphone_address_as_string_uri_only(from);
char *from_message=(char *)g_object_get_data(G_OBJECT(w),"from_message");
gchar *from_message=(gchar *)g_object_get_data(G_OBJECT(w),"from_message");
GList *list=g_object_get_data(G_OBJECT(w),"list");
time_t t;
char buf[80];
......@@ -148,8 +153,8 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter," : ",-1,"bold",me ? "bg":NULL,NULL);
gtk_text_buffer_get_end_iter(buffer,&iter);
gtk_text_buffer_insert(buffer,&iter,"\n",-1);
ms_free(from_message);
g_object_set_data(G_OBJECT(w),"from_message",from_str);
g_free(from_message);
g_object_set_data(G_OBJECT(w),"from_message",g_strdup(from_str));
}
gtk_text_buffer_get_end_iter(buffer,&iter);
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,linphone_chat_message_get_text(msg),-1,"margin",me ? "bg":NULL,NULL);
......@@ -193,6 +198,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
gtk_text_buffer_insert(buffer,&iter,"\n",-1);
GtkTextMark *mark=gtk_text_buffer_create_mark(buffer,NULL,&iter,FALSE);
gtk_text_view_scroll_mark_onscreen(text,mark);
ms_free(from_str);
}
const LinphoneAddress* linphone_gtk_get_used_identity(){
......@@ -292,6 +298,7 @@ void display_history_message(GtkWidget *chat_view,MSList *messages,const Linphon
MSList *it;
char *from_str;
char *with_str;
gchar *tmp;
for(it=messages;it!=NULL;it=it->next){
LinphoneChatMessage *msg=(LinphoneChatMessage *)it->data;
from_str=linphone_address_as_string_uri_only(linphone_chat_message_get_from(msg));
......@@ -301,7 +308,11 @@ void display_history_message(GtkWidget *chat_view,MSList *messages,const Linphon
strcmp(from_str,with_str)==0? FALSE : TRUE,
linphone_chat_message_get_chat_room(msg),msg,TRUE);
}
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
tmp=g_object_get_data(G_OBJECT(chat_view),"from_message");
if (tmp){
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
g_free(tmp);
}
ms_free(from_str);
ms_free(with_str);
linphone_gtk_free_list(messages);
......@@ -420,7 +431,7 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,
g_object_set_data(G_OBJECT(chat_view),"cr",cr);
g_object_set_data(G_OBJECT(linphone_gtk_get_widget(main_window,"contact_list")),"chatview",(gpointer)chat_view);
messages=linphone_chat_room_get_history(cr,NB_MSG_HIST);
g_object_set_data(G_OBJECT(chat_view),"from_message",uri_str);
g_object_set_data(G_OBJECT(chat_view),"from_message",g_strdup(uri_str));
display_history_message(chat_view,messages,uri);
}
ms_free(from_str);
......
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