--- a/ui/gtk/text.c Fri Mar 28 20:03:01 2014 +0100 +++ b/ui/gtk/text.c Fri Mar 28 20:03:49 2014 +0100 @@ -132,15 +132,22 @@ if(mgr->cur) { UcxList *elm = mgr->cur->next; - while(elm) { - ui_free_textbuf_op(elm->data); - UcxList *next = elm->next; - ucx_list_remove(mgr->begin, elm); - elm = next; + if(elm) { + mgr->cur->next = NULL; + while(elm) { + elm->prev = NULL; + UcxList *next = elm->next; + ui_free_textbuf_op(elm->data); + free(elm); + elm = next; + } } UiTextBufOp *last_op = mgr->cur->data; - if(ui_check_insertstr(last_op->text, last_op->len, text, length) == 0) { + if( + last_op->type == UI_TEXTBUF_INSERT && + ui_check_insertstr(last_op->text, last_op->len, text, length) == 0) + { // append text to last op int ln = last_op->len; char *newtext = malloc(ln + length + 1); @@ -186,11 +193,15 @@ if(mgr->cur) { UcxList *elm = mgr->cur->next; - while(elm) { - ui_free_textbuf_op(elm->data); - UcxList *next = elm->next; - ucx_list_remove(mgr->begin, elm); - elm = next; + if(elm) { + mgr->cur->next = NULL; + while(elm) { + elm->prev = NULL; + UcxList *next = elm->next; + ui_free_textbuf_op(elm->data); + free(elm); + elm = next; + } } } @@ -223,7 +234,7 @@ void ui_free_textbuf_op(UiTextBufOp *op) { if(op->text) { - g_free(op->text); + free(op->text); } free(op); }