Skip to content

Commit

Permalink
Fixed group chats sharing the same input buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Doom032 committed Mar 24, 2015
1 parent 295bbc9 commit 5159e09
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions list.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ static void selectitem(ITEM *i)

edit_resetfocus();

// deselect old item

if(sitem->item == ITEM_FRIEND) {
FRIEND *f = sitem->data;

Expand All @@ -168,15 +170,15 @@ static void selectitem(ITEM *i)
GROUPCHAT *g = sitem->data;

free(g->typed);
g->typed_length = edit_msg.length;
g->typed = malloc(edit_msg.length);
memcpy(g->typed, edit_msg.data, edit_msg.length);
g->typed_length = edit_msg_group.length;
g->typed = malloc(edit_msg_group.length);
memcpy(g->typed, edit_msg_group.data, edit_msg_group.length);

g->msg.scroll = messages_group.panel.content_scroll->d;

g->edit_history = edit_msg.history;
g->edit_history_cur = edit_msg.history_cur;
g->edit_history_length = edit_msg.history_length;
g->edit_history = edit_msg_group.history;
g->edit_history_cur = edit_msg_group.history_cur;
g->edit_history_length = edit_msg_group.history_length;
}

if(sitem->item == ITEM_SETTINGS) {
Expand All @@ -191,6 +193,8 @@ static void selectitem(ITEM *i)
button_transfer.disabled = 0;
}

// select new item

if(i->item == ITEM_FRIEND) {
FRIEND *f = i->data;

Expand Down Expand Up @@ -223,8 +227,8 @@ static void selectitem(ITEM *i)
if(i->item == ITEM_GROUP) {
GROUPCHAT *g = i->data;

memcpy(edit_msg.data, g->typed, g->typed_length);
edit_msg.length = g->typed_length;
memcpy(edit_msg_group.data, g->typed, g->typed_length);
edit_msg_group.length = g->typed_length;

messages_group.data = &g->msg;
messages_updateheight(&messages_group);
Expand All @@ -236,9 +240,9 @@ static void selectitem(ITEM *i)

g->msg.id = g - group;

edit_msg.history = g->edit_history;
edit_msg.history_cur = g->edit_history_cur;
edit_msg.history_length = g->edit_history_length;
edit_msg_group.history = g->edit_history;
edit_msg_group.history_cur = g->edit_history_cur;
edit_msg_group.history_length = g->edit_history_length;
}

if(i->item == ITEM_SETTINGS) {
Expand Down

0 comments on commit 5159e09

Please sign in to comment.