BKE_library_make_local(): some minor improvements.
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 11 Nov 2016 22:15:55 +0000 (23:15 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 11 Nov 2016 22:17:52 +0000 (23:17 +0100)
Do not set 'real user' to groups every time we run the first clearing loop.

And do fully clear properly LIB_TAG_DOIT (this is not yet enforced in
existing code, but would love to get to that stage in future, so let's
do it at least with new code!).

source/blender/blenkernel/intern/library.c

index d8d700d296cbca8d361b535a8482ff981cbeb1ed..823901d286f5bd2d819e4ddd9517a716458141de 100644 (file)
@@ -1745,6 +1745,12 @@ void BKE_library_make_local(
                if (old_to_new_ids) {
                        BLI_ghash_insert(old_to_new_ids, id, id->newid);
                }
+
+               /* Special hack for groups... Thing is, since we can't instantiate them here, we need to ensure
+                * they remain 'alive' (only instantiation is a real group 'user'... *sigh* See T49722. */
+               if (GS(id->name) == ID_GR && (id->tag & LIB_TAG_INDIRECT) != 0) {
+                       id_us_ensure_real(id->newid);
+               }
        }
 
        /* Step 5: remove datablocks that have been copied to be localized and are no more used in the end...
@@ -1794,11 +1800,6 @@ void BKE_library_make_local(
                                        ob->proxy = ob->proxy_from = ob->proxy_group = NULL;
                                }
                        }
-                       /* Special hack for groups... Thing is, since we can't instantiate them here, we need to ensure
-                        * they remain 'alive' (only instantiation is a real group 'user'... *sigh* See T49722. */
-                       else if (GS(id->name) == ID_GR && (id->tag & LIB_TAG_INDIRECT) != 0) {
-                               id_us_ensure_real(id->newid);
-                       }
 
                        if (!is_local) {
                                if (!is_lib) {  /* Not used at all, we can free it! */
@@ -1852,6 +1853,7 @@ void BKE_library_make_local(
 #endif
                        ((LinkNode *)it->link)->link = NULL;  /* Not strictly necessary, but safer (see T49903)... */
                        it->link = NULL;
+                       id->tag &= ~LIB_TAG_DOIT;
                }
        }