Another attempt at fixing T81963: Random rare crashes in override code.

Adding another pass of ensuring valid up-to-date pose data in RNA
function itself...
This commit is contained in:
Bastien Montagne 2020-11-02 11:56:34 +01:00
parent 2b98a9269b
commit dca65390f0
2 changed files with 24 additions and 1 deletions

View File

@ -1359,7 +1359,7 @@ bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
}
if (GS(local->name) == ID_OB) {
/* Our beloved pose's bone cross-data pointers.. Usually, depsgraph evaluation would
/* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
* ensure this is valid, but in some situations (like hidden collections etc.) this won't
* be the case, so we need to take care of this ourselves. */
Object *ob_local = (Object *)local;

View File

@ -26,6 +26,7 @@
#include "DNA_constraint_types.h"
#include "DNA_key_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@ -37,6 +38,7 @@
# include "PIL_time_utildefines.h"
#endif
#include "BKE_armature.h"
#include "BKE_idprop.h"
#include "BKE_lib_override.h"
#include "BKE_main.h"
@ -593,6 +595,27 @@ bool RNA_struct_override_matches(Main *bmain,
}
#endif
if (ptr_local->owner_id == ptr_local->data && GS(ptr_local->owner_id->name) == ID_OB) {
/* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
* ensure this is valid, but in some situations (like hidden collections etc.) this won't
* be the case, so we need to take care of this ourselves.
*
* Note: Typically callers of this function (from BKE_lib_override area) will already have
* ensured this. However, studio is still reporting sporadic, unreproducible crashes due to
* invalid pose data, so think there are still some cases where some armatures are somehow
* missing updates (possibly due to dependencies?). Since calling this function on same ID
* several time is almost free, and safe even in a threaded context as long as it has been done
* at least once first outside of threaded processing, we do it another time here. */
Object *ob_local = (Object *)ptr_local->owner_id;
if (ob_local->type == OB_ARMATURE) {
Object *ob_reference = (Object *)ptr_local->owner_id->override_library->reference;
BLI_assert(ob_local->data != NULL);
BLI_assert(ob_reference->data != NULL);
BKE_pose_ensure(bmain, ob_local, ob_local->data, true);
BKE_pose_ensure(bmain, ob_reference, ob_reference->data, true);
}
}
iterprop = RNA_struct_iterator_property(ptr_local->type);
for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid;