Commit 469cd9e5 authored by Andrea Schaefer's avatar Andrea Schaefer

Merge branch 'spam-crash' into 'master'

chatty-conversation: Don't crash on conversation with not yet buddies

Closes #82

See merge request !36
parents e86b8f7b 6a07ce4d
Pipeline #4219 passed with stages
in 5 minutes and 11 seconds
......@@ -1067,7 +1067,8 @@ chatty_conv_add_message_history_to_conv (gpointer data)
GList *msgs = NULL;
ChattyLog *log_data = NULL;
PurpleAccount *account;
gchar *name = NULL;
PurpleBuddy *buddy;
g_autofree gchar *name = NULL;
const gchar *conv_name;
const gchar *b_name;
gchar *time_stamp;
......@@ -1075,7 +1076,7 @@ chatty_conv_add_message_history_to_conv (gpointer data)
GList *history = NULL;
guint msg_dir;
gboolean im;
g_auto(GStrv) line_split = NULL;
ChattyConversation *chatty_conv = data;
im = (chatty_conv->active_conv->type == PURPLE_CONV_TYPE_IM);
......@@ -1094,12 +1095,20 @@ chatty_conv_add_message_history_to_conv (gpointer data)
return FALSE;
}
b_name = purple_buddy_get_alias (purple_find_buddy (account, conv_name));
buddy = purple_find_buddy (account, conv_name);
if (!buddy) {
/* Not in buddy list yet */
b_name = conv_name;
} else {
b_name = purple_buddy_get_alias (buddy);
}
line_split = g_strsplit (b_name, "/", -1);
name = g_strdup (line_split[0]);
// limit the log-list to MAX_MSGS msgs since we currently have no
// infinite scrolling implemented
for (int i = 0; history && i < MAX_MSGS; history = history->next) {
g_auto(GStrv) line_split = NULL;
g_auto(GStrv) logs = NULL;
g_autofree gchar *read_log = purple_log_read ((PurpleLog*)history->data, NULL);
g_autofree gchar *stripped = purple_markup_strip_html (read_log);
......@@ -1114,9 +1123,6 @@ chatty_conv_add_message_history_to_conv (gpointer data)
msgs = g_list_prepend (msgs, (gpointer)log_data);
}
}
line_split = g_strsplit (b_name, "/", -1);
name = g_strdup (line_split[0]);
}
g_list_foreach (history, (GFunc)purple_log_free, NULL);
......@@ -1152,7 +1158,6 @@ chatty_conv_add_message_history_to_conv (gpointer data)
g_list_foreach (msgs, (GFunc)g_free, NULL);
g_list_free (msgs);
g_free (name);
}
g_object_set_data (G_OBJECT (chatty_conv->msg_entry),
......
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