Initial step for IDTypeInfo refactor 'cleanup' project.
[blender.git] / source / blender / blenkernel / intern / lib_id_delete.c
index f2fa6946d4bfb7bccb83d6033e860ff54a9300d2..d47510ea9af55bbff0a98148b1d58998440901f5 100644 (file)
@@ -66,6 +66,7 @@
 #include "BKE_font.h"
 #include "BKE_gpencil.h"
 #include "BKE_idprop.h"
+#include "BKE_idtype.h"
 #include "BKE_image.h"
 #include "BKE_ipo.h"
 #include "BKE_key.h"
@@ -124,6 +125,15 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
 
 void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
 {
+  const IDTypeInfo *idtype_info = BKE_idtype_get_info_from_id(id);
+
+  if (idtype_info != NULL) {
+    if (idtype_info->free_data != NULL) {
+      idtype_info->free_data(id);
+    }
+    return;
+  }
+
   const short type = GS(id->name);
   switch (type) {
     case ID_SCE: