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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-18 17:24:23 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-18 17:27:29 +0300
commit5d58b7f073987543d8d952587a8ffd1268ca443e (patch)
tree810d44ccd3621deda8c26b30a8c56990f3ab3dbc /source
parent2c12c9b61e5081a98b9ba40d9f8c7d9f63fc9725 (diff)
Fix T61660: Wrong user counter on curves with shared material.
Patch by @sergey. Note that this is really a bad thing actually, ideally we should never get that situation (IDs in Main referencing temp IDs outside of it). That can lead to many possible similar cases... Fixing that is not trivial though, so for now we'll have to live with it, until we have migrated *all* of our temp datablocks generation outside of Main's.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/library_remap.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 92b3e581fa5..93ea5c35213 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -245,10 +245,19 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
if (cb_flag & IDWALK_CB_USER) {
- id_us_min(old_id);
- /* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
- if (new_id)
+ /* NOTE: We don't user-count IDs which are not in the main database.
+ * This is because in certain conditions we can have datablocks in
+ * the main which are referencing datablocks outside of it.
+ * For example, BKE_mesh_new_from_object() called on an evaluated
+ * object will cause such situation.
+ */
+ if ((old_id->tag & LIB_TAG_NO_MAIN) == 0) {
+ id_us_min(old_id);
+ }
+ if (new_id != NULL && (new_id->tag & LIB_TAG_NO_MAIN) == 0) {
+ /* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
new_id->us++;
+ }
}
else if (cb_flag & IDWALK_CB_USER_ONE) {
id_us_ensure_real(new_id);