[Bf-blender-cvs] [965d964] id-remap: Minor update/cleanup on usercount, from work done in master.

Bastien Montagne noreply at git.blender.org
Tue Nov 10 14:48:30 CET 2015


Commit: 965d9649c46f960255981007c210aecbb20cb02c
Author: Bastien Montagne
Date:   Tue Nov 10 14:47:38 2015 +0100
Branches: id-remap
https://developer.blender.org/rB965d9649c46f960255981007c210aecbb20cb02c

Minor update/cleanup on usercount, from work done in master.

===================================================================

M	source/blender/blenkernel/intern/library.c
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index e2f6630..1a997a3 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1074,9 +1074,8 @@ static bool foreach_libblock_remap_callback(void *user_data, ID **id_p, int cb_f
 		else {
 			*id_p = new_id;
 			if (cb_flag & IDWALK_USER) {
-				old_id->us--;
-				if (new_id)
-					new_id->us++;
+				id_us_min(old_id);
+				id_us_plus(new_id); /* XXX Check, do we really want to handle LIB_INDIRECT/LIB_EXTERN here? */
 			}
 			else if (cb_flag & IDWALK_USER_ONE) {
 				id_us_ensure_real(new_id);
@@ -1203,7 +1202,7 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
 
 			if (base) {
 				BKE_scene_base_unlink(sce, base);
-				base->object->id.us--;
+				id_us_min(&base->object->id);
 				MEM_freeN(base);
 			}
 		}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index b5bf29b..a5cf81d 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3123,10 +3123,8 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 					BKE_libblock_remap_locked(bmain, old_id, new_id, false);
 
 					if (old_id->flag & LIB_FAKEUSER) {
-						old_id->flag &= ~LIB_FAKEUSER;
-						old_id->us--;
-						new_id->flag |= LIB_FAKEUSER;
-						new_id->us++;
+						id_fake_user_clear(old_id);
+						id_fake_user_set(new_id);
 					}
 
 					printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
@@ -3259,10 +3257,8 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 					BKE_libblock_remap_locked(bmain, old_id, new_id, true);
 
 					if (old_id->flag & LIB_FAKEUSER) {
-						old_id->flag &= ~LIB_FAKEUSER;
-						old_id->us--;
-						new_id->flag |= LIB_FAKEUSER;
-						new_id->us++;
+						id_fake_user_clear(old_id);
+						id_fake_user_set(new_id);
 					}
 
 					printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
@@ -3289,7 +3285,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 
 			if (num_ids == 0) {
 				/* Nothing uses old lib anymore, we can get rid of it. */
-				lib->id.us--;
+				id_us_min(&lib->id);
 				if (lib->id.us == 0) {
 					BKE_libblock_free(bmain, (ID *)lib);
 				}




More information about the Bf-blender-cvs mailing list