[Bf-blender-cvs] [febb2351ad3] master: Fix ShapeKeys not being deleted together with their owner ID.

Bastien Montagne noreply at git.blender.org
Mon Jun 29 17:28:09 CEST 2020


Commit: febb2351ad35c26e0102f2db655694151eab382d
Author: Bastien Montagne
Date:   Fri Jun 26 17:57:12 2020 +0200
Branches: master
https://developer.blender.org/rBfebb2351ad35c26e0102f2db655694151eab382d

Fix ShapeKeys not being deleted together with their owner ID.

Consistency with e.g. copying (copying a mesh also duplicates its
shapekey typically).

Baby step towards getting rid of this horrible ID, some day...

Note that for now we only do that when taking BMain into account, fancy
code dealing with non-main IDs and such has to deal with those itself.

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

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

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

diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 7c96d0a6401..b4f2caac861 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -24,6 +24,7 @@
 
 /* all types are needed here, in order to do memory operations */
 #include "DNA_ID.h"
+#include "DNA_key_types.h"
 
 #include "BLI_utildefines.h"
 
@@ -32,6 +33,7 @@
 #include "BKE_anim_data.h"
 #include "BKE_idprop.h"
 #include "BKE_idtype.h"
+#include "BKE_key.h"
 #include "BKE_lib_id.h"
 #include "BKE_lib_override.h"
 #include "BKE_lib_remap.h"
@@ -146,6 +148,13 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
     BKE_libblock_relink_ex(bmain, id, NULL, NULL, 0);
   }
 
+  if ((flag & LIB_ID_FREE_NO_MAIN) == 0) {
+    Key *key = BKE_key_from_id(id);
+    if (key != NULL) {
+      BKE_id_free_ex(bmain, &key->id, flag, use_flag_from_idtag);
+    }
+  }
+
   BKE_libblock_free_datablock(id, flag);
 
   /* avoid notifying on removed data */



More information about the Bf-blender-cvs mailing list