diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-06-02 21:52:06 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-06-02 21:52:06 +0400 |
commit | d8c2709414ec3b25c2bdaeea57eb26c2ff91f977 (patch) | |
tree | 590b4a6151a11ad2618a834aea2dfc4eafe49761 /source/blender/blenkernel/intern/text.c | |
parent | 5506ab080d1f03acd9e0e09a43b244b2ccece544 (diff) |
Better API design for making text datablocks after loading.
An optional 'internal' argument was added to the bpy.data.texts.load() operator.
The changes in revision 57153 were reverted, so that the is_in_memory and is_dirty
properties of text datablocks are not editable again.
In the C API layer, BKE_text_load_ex() was introduced to allow for optionally
making text datablocks internal after loading.
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 470de8a205d..296f25e303e 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -362,7 +362,7 @@ int BKE_text_reload(Text *text) return 1; } -Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) +Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const bool is_internal) { FILE *fp; int i, llen, len; @@ -392,8 +392,13 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) len = ftell(fp); fseek(fp, 0L, SEEK_SET); - ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); - strcpy(ta->name, file); + if (is_internal == false) { + ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); + strcpy(ta->name, file); + } + else { + ta->flags |= TXT_ISMEM | TXT_ISDIRTY; + } init_undo_text(ta); @@ -460,6 +465,11 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) return ta; } +Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) +{ + return BKE_text_load_ex(bmain, file, relpath, false); +} + Text *BKE_text_copy(Text *ta) { Text *tan; |