diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-09 10:21:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-09 10:21:45 +0400 |
commit | d4ff53b760f51d791860b25385f2f9716740d586 (patch) | |
tree | 6849d8fe81f9352b10d3e113d64e5057040cf7ea /source/blender/blenloader | |
parent | 750b30c7dda4b46eb41f0ad611bae0a739b34610 (diff) |
fix [#36066] crash when Tab out text object
the way Curve.len is used at the moment is really stupid, calculate string size on save for now, but should really store the length in bytes and total number of characters.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 9b6699f3f21..dd4361be1ff 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1642,13 +1642,6 @@ static void write_mballs(WriteData *wd, ListBase *idbase) } } -static int amount_of_chars(char *str) -{ - // Since the data is saved as UTF-8 to the cu->str - // The cu->len is not same as the strlen(cu->str) - return strlen(str); -} - static void write_curves(WriteData *wd, ListBase *idbase) { Curve *cu; @@ -1666,8 +1659,12 @@ static void write_curves(WriteData *wd, ListBase *idbase) if (cu->adt) write_animdata(wd, cu->adt); if (cu->vfont) { - writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str); - writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo); + /* TODO, sort out 'cu->len', in editmode its character, object mode its bytes */ + int len_bytes; + int len_chars = BLI_strlen_utf8_ex(cu->str, &len_bytes); + + writedata(wd, DATA, len_bytes + 1, cu->str); + writestruct(wd, DATA, "CharInfo", len_chars + 1, cu->strinfo); writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb); } else { |