Fix #115117: Crash displaying status info on undo with subsurf mesh

After undo, a depsgraph update could free run-time modifier data.

In the case of the subsurf modifier a reference to this is held
in the meshes run-time data which also needs to be cleared.
This commit is contained in:
Campbell Barton
2024-01-12 12:16:49 +11:00
parent 3aa3743b6e
commit e202c81b41

View File

@@ -15,6 +15,7 @@
#include "BLI_listbase.h"
#include "BKE_action.h"
#include "BKE_mesh_types.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
@@ -161,6 +162,15 @@ void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(backup.type);
BLI_assert(modifier_type_info != nullptr);
modifier_type_info->free_runtime_data(backup.runtime);
if (backup.type == eModifierType_Subsurf) {
if (object->type == OB_MESH) {
Mesh *mesh = (Mesh *)object->data;
if (mesh->runtime->subsurf_runtime_data == backup.runtime) {
mesh->runtime->subsurf_runtime_data = nullptr;
}
}
}
}
}