[Bf-blender-cvs] [db33f64] id-remap: Fix cases where previously indirect lib becomes direct one after some relocate...

Bastien Montagne noreply at git.blender.org
Mon Sep 21 21:58:47 CEST 2015


Commit: db33f64a897d117ce79b7a90bbca17a2ef56d648
Author: Bastien Montagne
Date:   Mon Sep 21 20:48:31 2015 +0200
Branches: id-remap
https://developer.blender.org/rBdb33f64a897d117ce79b7a90bbca17a2ef56d648

Fix cases where previously indirect lib becomes direct one after some relocate...

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

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

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

diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 3eef6e5..712c477 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3120,6 +3120,12 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 					}
 
 					printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
+
+					/* In some cases, new_id might become direct link, remove parent of library in this case. */
+					if (new_id->lib->parent && (new_id->flag & LIB_INDIRECT) == 0) {
+						BLI_assert(0);  /* Should not happen in reload case... */
+						new_id->lib->parent = NULL;
+					}
 				}
 
 				if (old_id->us > 0) {
@@ -3235,7 +3241,6 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 				if (new_id) {
 					printf("before remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
 					BKE_libblock_remap_locked(bmain, old_id, new_id, true);
-					printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
 
 					if (old_id->flag & LIB_FAKEUSER) {
 						old_id->flag &= ~LIB_FAKEUSER;
@@ -3243,6 +3248,13 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, const bool reloa
 						new_id->flag |= LIB_FAKEUSER;
 						new_id->us++;
 					}
+
+					printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
+
+					/* In some cases, new_id might become direct link, remove parent of library in this case. */
+					if (new_id->lib->parent && (new_id->flag & LIB_INDIRECT) == 0) {
+						new_id->lib->parent = NULL;
+					}
 				}
 			}




More information about the Bf-blender-cvs mailing list