Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-07-19 14:53:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-07-19 14:58:26 +0300
commit69ba3b98e4dc84e40fcb623fcdbc7214361466e7 (patch)
treef598f05c139c6d1e300fb45ea26d83a8d3374801 /source/blender
parent48418ec125413be95cecbb71599b714d258c3daf (diff)
Fix new Text ID usercount handling in add/load cases.
Text datablocks should always have a 'single user' flag set, and they usually do not have any user (since neither text editor itself, nor Freestyle usage are text users - the second is odd btw...), the only one am aware of is the script node (e.g. for OSL). Add text case was simply not doing anything, so added. Load text case was doing things in inversed logic (setting user count to zero in BKE, then setting 'real user' flag in ED code). Made it the other way around (BKE ID creation code should not care about usercount usually, this is up to higher-level code to decide what to do (operators, RNA...). Note: tried to check all cases, but there might very well be some more hidden bugs here...
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/text.c5
-rw-r--r--source/blender/editors/space_text/text_ops.c6
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index b922aabc171..056229ceb1c 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -166,6 +166,8 @@ Text *BKE_text_add(Main *bmain, const char *name)
Text *ta;
ta = BKE_libblock_alloc(bmain, ID_TXT, name, 0);
+ /* Texts always have 'real' user (see also read code). */
+ id_us_ensure_real(&ta->id);
BKE_text_init(ta);
@@ -354,7 +356,8 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
}
ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(filepath_abs), 0);
- ta->id.us = 0;
+ /* Texts always have 'real' user (see also read code). */
+ id_us_ensure_real(&ta->id);
BLI_listbase_clear(&ta->lines);
ta->curl = ta->sell = NULL;
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 4992a73f936..8f7bd83cbf4 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -241,6 +241,8 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
PropertyRNA *prop;
text = BKE_text_add(bmain, "Text");
+ /* Texts have no user by default... Only the 'real' user flag. */
+ id_us_min(&text->id);
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
@@ -307,6 +309,8 @@ static int text_open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", str);
text = BKE_text_load_ex(bmain, str, BKE_main_blendfile_path(bmain), internal);
+ /* Texts have no user by default... Only the 'real' user flag. */
+ id_us_min(&text->id);
if (!text) {
if (op->customdata) {
@@ -322,8 +326,6 @@ static int text_open_exec(bContext *C, wmOperator *op)
/* hook into UI */
pprop = op->customdata;
- id_us_ensure_real(&text->id);
-
if (pprop->prop) {
RNA_id_pointer_create(&text->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, NULL);
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index d7acbb40bb8..fec991e16da 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -555,6 +555,8 @@ static Text *rna_Main_texts_load(Main *bmain,
errno = 0;
txt = BKE_text_load_ex(bmain, filepath, BKE_main_blendfile_path(bmain), is_internal);
+ /* Texts have no user by default... Only the 'real' user flag. */
+ id_us_min(&txt->id);
if (!txt) {
BKE_reportf(reports,