Fix T73472: Crash in override code on dirty pose bone pointers.

Usual issue from those dear Bone pointers in pose data...

Note that this is more like minimal-risk, quick fix, it's nothing like
'nice to have' code. Think proper solution would be to refactor handling
of those kind of 'caches' to ensure they are valid/up-to-date in a much
easier way, at the very least.

Ideal solution being to get fully rid of those horrors, of course, but
let's not dream here. ;)
This commit is contained in:
Bastien Montagne 2020-02-03 14:29:18 +01:00
parent bc3d7faab7
commit f13940e883
Notes: blender-bot 2023-02-14 08:42:54 +01:00
Referenced by issue #73472, Saving After Relocating a Linked Blend File Crashes
1 changed files with 35 additions and 0 deletions

View File

@ -30,6 +30,8 @@
#include "DNA_object_types.h"
#include "DEG_depsgraph.h"
#include "BKE_armature.h"
#include "BKE_library.h"
#include "BKE_library_override.h"
#include "BKE_library_remap.h"
@ -579,6 +581,17 @@ bool BKE_override_library_status_check_local(Main *bmain, ID *local)
BLI_assert(GS(local->name) == GS(reference->name));
if (GS(local->name) == ID_OB) {
/* Our beloved pose's bone cross-data pointers... Usually, depsgraph evaluation would ensure
* this is valid, but in some cases (like hidden collections etc.) this won't be the case, so
* we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
if (ob_local->data != NULL && ob_local->type == OB_ARMATURE && ob_local->pose != NULL &&
ob_local->pose->flag & POSE_RECALC) {
BKE_pose_rebuild(bmain, ob_local, ob_local->data, true);
}
}
/* Note that reference is assumed always valid, caller has to ensure that itself. */
PointerRNA rnaptr_local, rnaptr_reference;
@ -633,6 +646,17 @@ bool BKE_override_library_status_check_reference(Main *bmain, ID *local)
}
}
if (GS(local->name) == ID_OB) {
/* Our beloved pose's bone cross-data pointers... Usually, depsgraph evaluation would ensure
* this is valid, but in some cases (like hidden collections etc.) this won't be the case, so
* we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
if (ob_local->data != NULL && ob_local->type == OB_ARMATURE && ob_local->pose != NULL &&
ob_local->pose->flag & POSE_RECALC) {
BKE_pose_rebuild(bmain, ob_local, ob_local->data, true);
}
}
PointerRNA rnaptr_local, rnaptr_reference;
RNA_id_pointer_create(local, &rnaptr_local);
RNA_id_pointer_create(reference, &rnaptr_reference);
@ -678,6 +702,17 @@ bool BKE_override_library_operations_create(Main *bmain, ID *local, const bool f
return ret;
}
if (GS(local->name) == ID_OB) {
/* Our beloved pose's bone cross-data pointers... Usually, depsgraph evaluation would ensure
* this is valid, but in some cases (like hidden collections etc.) this won't be the case, so
* we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
if (ob_local->data != NULL && ob_local->type == OB_ARMATURE && ob_local->pose != NULL &&
ob_local->pose->flag & POSE_RECALC) {
BKE_pose_rebuild(bmain, ob_local, ob_local->data, true);
}
}
PointerRNA rnaptr_local, rnaptr_reference;
RNA_id_pointer_create(local, &rnaptr_local);
RNA_id_pointer_create(local->override_library->reference, &rnaptr_reference);