Fix T58928: New Action causes crash when duplicating bone

Basically, armature update is not supposed to be run in edit mode.
This worked in master and new dependency graph because nobody was
tagging armature for an update.

But with all those copy-on-write and other things we can't ensure
tag doesn't happen (and we shouldn't). So now we ensure unwanted
code is not run from the code itself.

P.S. Deeper reason of this goes to the optimization of not updating
pose channels when in edit mode. Since pose doesn't define anything
there we don't want to be bothered with a pose update after every
operation which changes it.
This commit is contained in:
Sergey Sharybin 2018-12-10 15:59:15 +01:00
parent d7e7c4ddf7
commit 9fa408f51b
Notes: blender-bot 2023-02-14 19:23:18 +01:00
Referenced by commit 1ca7b6ca85, Fix T59569: crashes when generate rig.
Referenced by issue #59511,  Missing maya input configuration
Referenced by issue #59293, Cannot assign shortcut to undo history
Referenced by issue #59177, Animplayer extreme zooms in when playing rendered animation.
Referenced by issue #59165, Text Editor - Pasting text kills undo steps
Referenced by issue #59141, Background colour slighly changes when moving view
Referenced by issue #59143, Frame Selected Doesn't work in Particle edit Mode (hair)
Referenced by issue blender/blender-addons#58928, New Action causes crash when duplicating bone
1 changed files with 30 additions and 8 deletions

View File

@ -640,13 +640,16 @@ void BKE_pose_eval_bone(struct Depsgraph *depsgraph,
Object *object,
int pchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
DEG_debug_print_eval_subdata(
depsgraph, __func__, object->id.name, object,
"pchan", pchan->name, pchan);
BLI_assert(object->type == OB_ARMATURE);
bArmature *armature = (bArmature *)object->data;
if (armature->edbo || (armature->flag & ARM_RESTPOS)) {
if (armature->flag & ARM_RESTPOS) {
Bone *bone = pchan->bone;
if (bone) {
copy_m4_m4(pchan->pose_mat, bone->arm_mat);
@ -677,11 +680,14 @@ void BKE_pose_constraints_evaluate(struct Depsgraph *depsgraph,
Object *object,
int pchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
DEG_debug_print_eval_subdata(
depsgraph, __func__, object->id.name, object,
"pchan", pchan->name, pchan);
bArmature *armature = (bArmature *)object->data;
if (armature->flag & ARM_RESTPOS) {
return;
}
@ -700,6 +706,10 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
struct Object *object,
int pchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
float imat[4][4];
DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
@ -707,7 +717,6 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
}
bArmature *armature = (bArmature *)object->data;
if (DEG_is_active(depsgraph) && armature->edbo == NULL) {
bPoseChannel *pchan_orig = pchan->orig_pchan;
copy_m4_m4(pchan_orig->pose_mat, pchan->pose_mat);
@ -725,12 +734,15 @@ void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph,
struct Object *object,
int pchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
if (pchan->bone != NULL && pchan->bone->segments > 1) {
BKE_pchan_bbone_segments_cache_compute(pchan);
bArmature *armature = (bArmature *)object->data;
if (DEG_is_active(depsgraph) && armature->edbo == NULL) {
if (DEG_is_active(depsgraph)) {
BKE_pchan_bbone_segments_cache_copy(pchan->orig_pchan, pchan);
}
}
@ -741,13 +753,16 @@ void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph,
Object *object,
int rootchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *rootchan = pose_pchan_get_indexed(object, rootchan_index);
DEG_debug_print_eval_subdata(
depsgraph, __func__, object->id.name, object,
"rootchan", rootchan->name, rootchan);
BLI_assert(object->type == OB_ARMATURE);
const float ctime = BKE_scene_frame_get(scene); /* not accurate... */
bArmature *armature = (bArmature *)object->data;
if (armature->flag & ARM_RESTPOS) {
return;
}
@ -760,13 +775,16 @@ void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
int rootchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
bPoseChannel *rootchan = pose_pchan_get_indexed(object, rootchan_index);
DEG_debug_print_eval_subdata(
depsgraph, __func__, object->id.name, object,
"rootchan", rootchan->name, rootchan);
BLI_assert(object->type == OB_ARMATURE);
const float ctime = BKE_scene_frame_get(scene); /* not accurate... */
bArmature *armature = (bArmature *)object->data;
if (armature->flag & ARM_RESTPOS) {
return;
}
@ -843,6 +861,10 @@ void BKE_pose_eval_proxy_copy_bone(
Object *object,
int pchan_index)
{
const bArmature *armature = (bArmature *)object->data;
if (armature->edbo != NULL) {
return;
}
BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);