Commit: 49b67b58aa9614f70769322ce595e9a8a5625633
Author: Bastien Montagne
Date:   Mon Dec 7 15:54:03 2015 +0100
Branches: id-remap
https://developer.blender.org/rB49b67b58aa9614f70769322ce595e9a8a5625633

Fix id-remap looper not 'freeing' 'use-one' id usercount.

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

M       source/blender/blenkernel/intern/library.c
M       source/blender/blenkernel/intern/library_query.c

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

diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index ada6ccb..6ad2f0b 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -182,6 +182,18 @@ void id_us_ensure_real(ID *id)
        }
 }
 
+static void id_us_clear_real(ID *id)
+{
+       if (id && (id->flag2 & LIB_EXTRAUSER)) {
+               if (id->flag2 & LIB_EXTRAUSER_SET) {
+                       const int limit = ID_FAKE_USERS(id);
+                       id->us--;
+                       BLI_assert(id->us >= limit);
+               }
+               id->flag2 &= ~(LIB_EXTRAUSER | LIB_EXTRAUSER_SET);
+       }
+}
+
 void id_us_plus(ID *id)
 {
        if (id) {
@@ -1209,6 +1221,8 @@ static void libblock_remap_data(
                id_fake_user_set(new_id);
        }
 
+       id_us_clear_real(old_id);
+
        if (new_id && (new_id->flag & LIB_INDIRECT) && (r_id_remap_data->status 
& ID_REMAP_IS_LINKED_DIRECT)) {
                new_id->flag &= ~LIB_INDIRECT;
                new_id->flag |= LIB_EXTERN;
diff --git a/source/blender/blenkernel/intern/library_query.c 
b/source/blender/blenkernel/intern/library_query.c
index 9fdac85..2292737 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -727,11 +727,14 @@ typedef struct IDUsersIter {
        int count;  /* Set by callback. */
 } IDUsersIter;
 
-static bool foreach_libblock_id_users_callback(void *user_data, ID **id_p, int 
UNUSED(cb_flag))
+static bool foreach_libblock_id_users_callback(void *user_data, ID **id_p, int 
cb_flag)
 {
        IDUsersIter *iter = user_data;
 
        if (*id_p && (*id_p == iter->id)) {
+               printf("%s uses %s (refcounted: %d, userone: %d, used_one: %d, 
used_one_active: %d)\n",
+                      iter->curr_id->name, iter->id->name, (cb_flag & 
IDWALK_USER) ? 1 : 0, (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
+                      (iter->id->flag2 & LIB_EXTRAUSER) ? 1 : 0, 
(iter->id->flag2 & LIB_EXTRAUSER_SET) ? 1 : 0);
                iter->count++;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to