Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-08-10 11:43:26 +0300
committerJeroen Bakker <jeroen@blender.org>2020-08-12 10:30:18 +0300
commit112416e4fb8ca85b6a2fa3d619eddd18b62ab0c2 (patch)
tree9037050d5ac38c1d423606c334543175593d1451
parentf2b71df549b5a3a667f6e5f618ac99951e204e50 (diff)
Fix T77847: "Add plane > align" causes crash when certain rigs are in the scene (2.83, fixed in 2.90).
Root of the issue was not fixed in 2.90, only hidden by the fact that we now re-read much less data during undo's that we used to, when some new datablock gets added or removed. This is not an ideal solution (as usual when dealing with data pointers shared across data-blocks), but it's decent enough. thanks a lot to @brecht for it! To be backported to 2.83 too.
-rw-r--r--source/blender/blenloader/intern/writefile.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 424a0e78847..d3052d9919c 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -150,6 +150,7 @@
#include "MEM_guardedalloc.h" // MEM_freeN
#include "BKE_action.h"
+#include "BKE_armature.h"
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
#include "BKE_collection.h"
@@ -1562,7 +1563,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
}
}
-static void write_pose(WriteData *wd, bPose *pose)
+static void write_pose(WriteData *wd, bPose *pose, bArmature *arm)
{
bPoseChannel *chan;
bActionGroup *grp;
@@ -1572,6 +1573,8 @@ static void write_pose(WriteData *wd, bPose *pose)
return;
}
+ BLI_assert(arm != NULL);
+
/* Write channels */
for (chan = pose->chanbase.first; chan; chan = chan->next) {
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
@@ -1584,11 +1587,15 @@ static void write_pose(WriteData *wd, bPose *pose)
write_motionpath(wd, chan->mpath);
- /* prevent crashes with autosave,
- * when a bone duplicated in editmode has not yet been assigned to its posechannel */
- if (chan->bone) {
+ /* Prevent crashes with autosave,
+ * when a bone duplicated in editmode has not yet been assigned to its posechannel.
+ * Also needed with memundo, in some cases we can store a step before pose has been
+ * properly rebuilt from previous undo step. */
+ Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
+ chan->bone;
+ if (bone != NULL) {
/* gets restored on read, for library armatures */
- chan->selectflag = chan->bone->flag & BONE_SELECTED;
+ chan->selectflag = bone->flag & BONE_SELECTED;
}
writestruct(wd, DATA, bPoseChannel, 1, chan);
@@ -1912,15 +1919,16 @@ static void write_object(WriteData *wd, Object *ob, const void *id_address)
writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits);
/* write_effects(wd, &ob->effect); */ /* not used anymore */
+ bArmature *arm = NULL;
if (ob->type == OB_ARMATURE) {
- bArmature *arm = ob->data;
+ arm = ob->data;
if (arm && ob->pose && arm->act_bone) {
BLI_strncpy(
ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
}
}
- write_pose(wd, ob->pose);
+ write_pose(wd, ob->pose, arm);
write_defgroups(wd, &ob->defbase);
write_fmaps(wd, &ob->fmaps);
write_constraints(wd, &ob->constraints);