Blender Git Loki

Git Commits -> Revision 6dc7266

Revision 6dc7266 by Philipp Oeser (master)
September 9, 2020, 12:12 (GMT)
Fix T80464: Crash deleting bone constraints when the armature layer is
not active

Caused by {rB608d9b5aa1f1}

Prior to rB608d9b5aa1f1, the constraint was gotten using **context**
[CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint) -- which is
valid for bones on hidden layers].
After rB608d9b5aa1f1, the constraint is found (or isnt) using
`edit_constraint_property_get` [this is **not** valid for bones on
hidden layers because internally `BKE_pose_channel_active` checks if the
bone is on an active layer].

Some observations:
- Every operator using `edit_constraint_property_get` doesnt work for
bones on inactive layers [delete, moveup, movedown, move to index (drag
n drop nowadays)]
-- moveup, movedown, move to index check if they could find a constraint
beforehand though (dont crash)
-- delete crashes (doesnt check if a constraint could actually be found)
- Every operator using `edit_constraint_property_get` for constraint
data doesnt work for bones on inactive layers [stretchto_reset,
limitdistance_reset, childof_set_inverse, ...]
-- these all check if they could find a constraint beforehand though
(dont crash)

This is because the poll function is using **context** to get the
constraint, the operators themselves use
**edit_constraint_property_get** which leads to inconsistent/unexpected
results.

Possible solutions were:
- [1] let the delete operator just work with the context constraint
again (like prior to rB608d9b5aa1f1) -- allows for deleting constraints
on bones in inactive layers
- [2] check if we could get a constraint -- prevents the crash, but does
**not** allow for deleting constraints on bones in inactive layers
- [3] make the poll `edit_constraint_poll_generic` be as strict as the
operators -- dont use **context** to get the constraint, but something
like **edit_constraint_property_get**
- [4] make the operators be more graceful and let them act on bones on
hidden layers -- let **edit_constraint_property_get** actually use the
same **context**

This patch implements [4], so poll an doperators are now in sync.
- prevents reported crash
- also enables operators for bone constraints on hidden layers
- also enables drag and drop reordering of constraints on hidden layers

This might be a candidate for 2.90.1? (if it is, take care to include
prior "Refactor getting constraints" refactoring commit)

Note: Adding constraints also doesnt work for bones on inactive layers
[that was the case in 2.79 as well -- it is also using
`BKE_pose_channel_active`]

Maniphest Tasks: T80464

Differential Revision: https://developer.blender.org/D8805

Commit Details:

Full Hash: 6dc7266cf1f4ee4e6e6eaa7e4949fcff11372479
Parent Commit: 9dcae4e
Lines Changed: +14, -34

Tehnyt: Miika HämäläinenViimeksi p?ivitetty: 07.11.2014 14:18 MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2020