[Bf-blender-cvs] [1fce66190a4] master: Fix/refactor `BKE_id_clear_newpoin` and `BKE_main_id_newptr_and_tag_clear`.

Bastien Montagne noreply at git.blender.org
Thu Sep 16 14:31:08 CEST 2021


Commit: 1fce66190a46ac47cac015b50913d0b05b3f087e
Author: Bastien Montagne
Date:   Thu Sep 16 12:14:21 2021 +0200
Branches: master
https://developer.blender.org/rB1fce66190a46ac47cac015b50913d0b05b3f087e

Fix/refactor `BKE_id_clear_newpoin` and `BKE_main_id_newptr_and_tag_clear`.

Those were not clearing embdeed IDs flags and `newid` pointers at all...

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

M	source/blender/blenkernel/intern/lib_id.c

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

diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 89e0ae9e7f0..9db2df06e42 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -338,10 +338,29 @@ void id_fake_user_clear(ID *id)
 
 void BKE_id_clear_newpoin(ID *id)
 {
-  if (id->newid) {
-    id->newid->tag &= ~LIB_TAG_NEW;
+  /* We assume that if this ID has no new ID, its embedded data has not either. */
+  if (id->newid == NULL) {
+    return;
   }
+
+  id->newid->tag &= ~LIB_TAG_NEW;
   id->newid = NULL;
+
+  /* Deal with embedded data too. */
+  Key *key = BKE_key_from_id(id);
+  if (key != NULL) {
+    BKE_id_clear_newpoin(&key->id);
+  }
+  bNodeTree *ntree = ntreeFromID(id);
+  if (ntree != NULL) {
+    BKE_id_clear_newpoin(&ntree->id);
+  }
+  if (GS(id->name) == ID_SCE) {
+    Collection *master_collection = ((Scene *)id)->master_collection;
+    if (master_collection != NULL) {
+      BKE_id_clear_newpoin(&master_collection->id);
+    }
+  }
 }
 
 static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data)
@@ -1763,8 +1782,7 @@ void BKE_main_id_newptr_and_tag_clear(Main *bmain)
   ID *id;
 
   FOREACH_MAIN_ID_BEGIN (bmain, id) {
-    id->newid = NULL;
-    id->tag &= ~LIB_TAG_NEW;
+    BKE_id_clear_newpoin(id);
   }
   FOREACH_MAIN_ID_END;
 }



More information about the Bf-blender-cvs mailing list