[Bf-blender-cvs] [92d3a152391] blender-v2.83-release: Fix broken shapekeys: check for 'NULL' `from` pointer too.

Bastien Montagne noreply at git.blender.org
Tue Feb 22 12:18:05 CET 2022


Commit: 92d3a152391a87c7bb04d6bcb52fb5446a0e1421
Author: Bastien Montagne
Date:   Fri Feb 18 12:11:59 2022 +0100
Branches: blender-v2.83-release
https://developer.blender.org/rB92d3a152391a87c7bb04d6bcb52fb5446a0e1421

Fix broken shapekeys: check for 'NULL' `from` pointer too.

Add check for `NULL` `from` pointer to `BLO_main_validate_shapekeys`,
and delete these shapekeys, as they are fully invalid and impossible to
recover.

Found in a studio production file (`animation
test/snow_parkour/shots/0040/0040.lighting.blend`, svn rev `1111`).
Would be nice to know how this was generated too...

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

M	source/blender/blenloader/intern/blend_validate.c

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

diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 33c5e3ac197..e053c3e1fc8 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -199,5 +199,20 @@ bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
 
   BKE_main_unlock(bmain);
 
+  /* NOTE: #BKE_id_delete also locks `bmain`, so we need to do this loop outside of the lock here.
+   */
+  LISTBASE_FOREACH_MUTABLE (Key *, shapekey, &bmain->shapekeys) {
+    if (shapekey->from != NULL) {
+      continue;
+    }
+
+    BKE_reportf(reports,
+                RPT_ERROR,
+                "Shapekey %s has an invalid 'from' pointer (%p), it will be deleted",
+                shapekey->id.name,
+                shapekey->from);
+    BKE_id_delete(bmain, shapekey);
+  }
+
   return is_valid;
 }



More information about the Bf-blender-cvs mailing list