The `BKE_material_clear_id()` didn't call `test_all_objects_materials()`, which caused the object and mesh material slot count to go out of sync.
The `BKE_material_clear_id()` didn't call `test_all_objects_materials()`, which caused the object and mesh material slot count to go out of sync.