Page MenuHome

Deleting bone constraints when the armature layer isn't active crashes Blender
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Win 10
Graphics card: RTX2070

Blender Version
Broken: 2.90, 2.91 alpha
Worked: 2.83.5
Caused by rB608d9b5aa1f1: UI: Add shortcuts for constraint panels

Short description of error
Deleting bone constraints when the armature layer isn't active crashes Blender

Exact steps for others to reproduce the error
The attached file has 2 bones in 1 armature. Bone.001 is constrained to Bone, and the two bones are in separate armature layers. With both layers active, deleting the constraint in Bone.001 works normally. But if layer 16 isn't active, doing the same thing will crash Blender.

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Sep 4 2020, 12:06 PM
Philipp Oeser (lichtwerk) claimed this task.
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Can confirm.

Caused by rB608d9b5aa1f1: UI: Add shortcuts for constraint panels

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:

  • [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 context

Whatever we decide upon: this might be a candidate for 2.90.1? Will check on all solutions, might go for the quick fix [1] first, then try [4]?

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]
Note: edit_constraint_invoke_properties also uses said context

Philipp Oeser (lichtwerk) triaged this task as High priority.Sep 4 2020, 2:54 PM
Philipp Oeser (lichtwerk) updated the task description. (Show Details)

Good find @Philipp Oeser (lichtwerk). I think it's important to have the poll function actually in sync with the rest of the operator; without that, it's rather useless. And first doing [1] and then trying [4] sounds good to me.