Fix T58652: Crash editing shape keys weirdness with instances

This commit is contained in:
Sergey Sharybin 2018-12-14 11:32:07 +01:00
parent 285cfef695
commit 7e6288cfe6
Notes: blender-bot 2023-07-10 10:12:37 +02:00
Referenced by issue #58652, blender 2.8 - hard crash - editing shape keys weirdness with instances
1 changed files with 28 additions and 0 deletions

View File

@ -109,6 +109,7 @@
#include "BKE_library_remap.h"
#include "BKE_linestyle.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_material.h"
#include "BKE_main.h"
#include "BKE_mball.h"
@ -517,6 +518,31 @@ static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **i
return IDWALK_RET_NOP;
}
static void id_copy_clear_runtime_if_needed(ID *id, int UNUSED(flag))
{
if (id == NULL) {
return;
}
/* TODO(sergey): Think of having a flag which will allow to share runtime
* fields of the ID.*/
switch ((ID_Type)GS(id->name)) {
case ID_OB:
{
Object *object = (Object *)id;
BKE_object_runtime_reset(object);
break;
}
case ID_ME:
{
Mesh *mesh = (Mesh *)id;
BKE_mesh_runtime_reset(mesh);
break;
}
default:
break;
}
}
/**
* Generic entry point for copying a datablock (new API).
*
@ -682,6 +708,8 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
(*r_newid)->lib = id->lib;
}
id_copy_clear_runtime_if_needed(*r_newid, flag);
return true;
}