Commit: ab5a591f9178c98ff1111d590263d58fe6ed7e27
Author: Bastien Montagne
Date:   Wed Nov 11 18:12:08 2015 +0100
Branches: id-remap
https://developer.blender.org/rBab5a591f9178c98ff1111d590263d58fe6ed7e27

Do not try to reload directly non-linkable datablocks (shapekeys),
those will get reloaded by 'owner' mesh anyway.

Why, why, why are shapekeys datablocks???

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

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 377cd03..eb2d7fd 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1078,8 +1078,9 @@ static bool foreach_libblock_remap_callback(void 
*user_data, ID **id_p, int cb_f
                const bool is_never_null = ((cb_flag & IDWALK_NEVER_NULL) && 
(new_id == NULL));
                const bool skip_never_null = (id_remap_data->flag & 
ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0;
 
+               if (GS(id->name) == ID_TXT)
                printf("\t\tIn %s (%p): remapping %s (%p) to %s (%p)\n",
-                      id->name, id, old_id->name, old_id, new_id ? 
new_id->name : "", new_id);
+                      id->name, id, old_id->name, old_id, new_id ? 
new_id->name : "<NONE>", new_id);
 
                /* Special hack in case it's Object->data and we are in edit 
mode (skipped_direct too). */
                if ((is_never_null && skip_never_null) ||
@@ -1163,11 +1164,12 @@ static void libblock_remap_data(
        r_id_remap_data->skipped_indirect = 0;
        r_id_remap_data->skipped_refcounted = 0;
 
+       if (id && GS(id->name) == ID_TXT)
        printf("%s: %s (%p) replaced by %s (%p)\n", __func__,
               old_id ? old_id->name : "", old_id, new_id ? new_id->name : "", 
new_id);
 
        if (id) {
-               printf("\tchecking id %s (%p, %p)\n", id->name, id, id->lib);
+//             printf("\tchecking id %s (%p, %p)\n", id->name, id, id->lib);
                r_id_remap_data->id = id;
                BKE_library_foreach_ID_link(id, 
foreach_libblock_remap_callback, (void *)r_id_remap_data, IDWALK_NOP);
        }
@@ -1203,9 +1205,9 @@ static void libblock_remap_data(
                new_id->flag |= LIB_EXTERN;
        }
 
-       printf("%s: %d occurences skipped (%d direct and %d indirect ones)\n", 
__func__,
-              r_id_remap_data->skipped_direct + 
r_id_remap_data->skipped_indirect,
-              r_id_remap_data->skipped_direct, 
r_id_remap_data->skipped_indirect);
+//     printf("%s: %d occurences skipped (%d direct and %d indirect ones)\n", 
__func__,
+//            r_id_remap_data->skipped_direct + 
r_id_remap_data->skipped_indirect,
+//            r_id_remap_data->skipped_direct, 
r_id_remap_data->skipped_indirect);
 }
 
 /** Replace all references in .blend file to \a old_id by \a new_id (if \a 
new_id is NULL, it unlinks \a old_id). */
@@ -1221,7 +1223,7 @@ void BKE_libblock_remap_locked(Main *bmain, void 
*old_idv, void *new_idv, const
        BLI_assert((new_id == NULL) || GS(old_id->name) == GS(new_id->name));
        BLI_assert(old_id != new_id);
 
-       printf("%s: %s (%p) replaced by %s (%p)\n", __func__, old_id->name, 
old_id, new_id ? new_id->name : "", new_id);
+//     printf("%s: %s (%p) replaced by %s (%p)\n", __func__, old_id->name, 
old_id, new_id ? new_id->name : "", new_id);
 
        libblock_remap_data(bmain, NULL, old_id, new_id, remap_flags, 
&id_remap_data);
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c 
b/source/blender/windowmanager/intern/wm_operators.c
index a5cf81d..33a0a0c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3072,7 +3072,12 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, const bool reloa
                        lba_idx = set_listbasepointers(bmain, lbarray);
                        while (lba_idx--) {
                                ID *id = lbarray[lba_idx]->first;
-                               const int idcode = id ? GS(id->name) : 0;
+                               const short idcode = id ? GS(id->name) : 0;
+
+                               if (!id || !BKE_idcode_is_linkable(idcode)) {
+                                       /* No need to reload non-linkable 
datatypes, those will get relinked with their 'users ID'. */
+                                       continue;
+                               }
 
                                for (; id; id = id->next) {
                                        if (id->lib == lib) {
@@ -3122,11 +3127,6 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, const bool reloa
                                        /* Note that here, we also want to 
replace indirect usages. */
                                        BKE_libblock_remap_locked(bmain, 
old_id, new_id, false);
 
-                                       if (old_id->flag & LIB_FAKEUSER) {
-                                               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);
 
                                        /* In some cases, new_id might become 
direct link, remove parent of library in this case. */
@@ -3155,7 +3155,7 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, const bool reloa
 
                                        BKE_reportf(op->reports, RPT_WARNING,
                                                    "Lib Reload: Replacing all 
references to old datablock '%s' by reloaded one failed, "
-                                                   "old (%d remaining users) 
one had to be kept and was renamed to '%s'",
+                                                   "old one (%d remaining 
users) had to be kept and was renamed to '%s'",
                                                    new_id->name, old_id->us, 
old_id->name);
                                }
                        }
@@ -3166,7 +3166,7 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, const bool reloa
                                WMLinkAppendDataItem *item = itemlink->link;
                                ID *old_id = item->customdata;
 
-                               printf("%p\n", old_id);
+//                             printf("%p\n", old_id);
 
                                if (old_id->us == 0) {
                                        BKE_libblock_free(bmain, old_id);
@@ -3294,8 +3294,8 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, const bool reloa
                        wm_link_append_data_free(lapp_data);
                }
 
-               /* Some datablocks can get reloaded/replaced 'silently' because 
they are not likable (shape keys e.g.),
-                * wo we need another loop here to clear old ones if possible. 
*/
+               /* Some datablocks can get reloaded/replaced 'silently' because 
they are not linkable (shape keys e.g.),
+                * so we need another loop here to clear old ones if possible. 
*/
                lba_idx = set_listbasepointers(bmain, lbarray);
                while (lba_idx--) {
                        ID *id = lbarray[lba_idx]->first;

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

Reply via email to