Fix T46720: Crash applying subsurf modifier

Freeing a modifier that had data in the derived mesh could crash
(applying or removing).
This commit is contained in:
Campbell Barton 2015-11-11 01:56:39 +11:00
parent 0024306362
commit 3b38fd6bf9
Notes: blender-bot 2023-02-14 08:27:36 +01:00
Referenced by issue #46720, Crash while entering edit mode if the object has subsurf and is child of another object with a bool modifier
2 changed files with 6 additions and 0 deletions

View File

@ -211,6 +211,9 @@ void BKE_object_free_modifiers(Object *ob)
/* same for softbody */
BKE_object_free_softbody(ob);
/* modifiers may have stored data in the DM cache */
BKE_object_free_derived_caches(ob);
}
void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)

View File

@ -324,6 +324,7 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
BLI_remlink(&ob->modifiers, md);
modifier_free(md);
BKE_object_free_derived_caches(ob);
return 1;
}
@ -709,6 +710,8 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
BLI_remlink(&ob->modifiers, md);
modifier_free(md);
BKE_object_free_derived_caches(ob);
return 1;
}