diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-15 06:11:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-15 06:11:40 +0400 |
commit | 283ee53085b1e215cbd0d8af91b0000660406bfe (patch) | |
tree | 498c2640d15304d71268157af098f3f146f077b0 /source/blender/blenkernel/intern | |
parent | cd8584aad56eb7fcc94dc4ebfbcde034aebbe3cd (diff) |
fix for deleting lines hanging the text editor when no markers are used, presence of markers still hangs.
also compiler warnings and some style edits.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 076dc3a35d7..d166592424d 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1764,7 +1764,7 @@ void txt_undo_add_op(Text *text, int op) txt_undo_store_cursors(text); text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1] = 0; + text->undo_buf[text->undo_pos + 1] = 0; } /* store an operator for a single character */ @@ -2386,20 +2386,22 @@ void txt_split_curline(Text *text) static void txt_delete_line(Text *text, TextLine *line) { TextMarker *mrk = NULL, *nxt; - int lineno = -1; if (!text) return; if (!text->curl) return; - lineno = txt_get_span(text->lines.first, line); - mrk = text->markers.first; - while (mrk) { - nxt = mrk->next; - if (mrk->lineno == lineno) - BLI_freelinkN(&text->markers, mrk); - else if (mrk->lineno > lineno) - mrk->lineno--; - mrk = nxt; + /* warning, this can be _slow_ when deleting many lines! */ + if ((mrk = text->markers.first)) { + int lineno = txt_get_span(text->lines.first, line); + mrk = text->markers.first; + while (mrk) { + nxt = mrk->next; + if (mrk->lineno == lineno) + BLI_freelinkN(&text->markers, mrk); + else if (mrk->lineno > lineno) + mrk->lineno--; + mrk = nxt; + } } BLI_remlink(&text->lines, line); @@ -2417,14 +2419,14 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) { char *tmp; TextMarker *mrk = NULL; - int lineno = -1; - + if (!text) return; if (!linea || !lineb) return; mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); if (mrk) { + int lineno; lineno = mrk->lineno; do { mrk->lineno--; @@ -2433,8 +2435,11 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) mrk = mrk->next; } while (mrk && mrk->lineno == lineno); } - if (lineno == -1) lineno = txt_get_span(text->lines.first, lineb); - +#if 0 /* UNUSED */ + if (lineno == -1) + lineno = txt_get_span(text->lines.first, lineb); +#endif + tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string"); strcpy(tmp, linea->line); |