diff options
author | Bastien Montagne <bastien@blender.org> | 2021-11-19 19:56:42 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-11-22 11:28:27 +0300 |
commit | 6eaa69c66c98d291b80331330391664415f759a4 (patch) | |
tree | dcdc7165f2e23ff22d57708a8b288bd72f1a9020 /source/blender/editors/interface | |
parent | 1b2ee3cf20777c737a116c44227b3193ae69cc74 (diff) |
Fix (unreported) broken handling of constraints reordering with liboverride.
New drag&drop reordering code would call constraints reordering operator
with the generic context, and not the one from the panel's layout.
missing the "constraint" member which is mandatory for poll function to
properly deal with override vs. local constraints.
This commit fixes it by generating a temp bContextStore in the panel
re-ordering callback.
NOTE: this fix will have to be extended to modifiers (which happen to
work currently because they have an 'active' status), and gpencil
modifiers (which are also broken currently).
Differential Revision: https://developer.blender.org/D13291
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1d349aa0596..ac638395c0b 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2036,6 +2036,15 @@ static void constraint_reorder(bContext *C, Panel *panel, int new_index) PointerRNA *con_ptr = UI_panel_custom_data_get(panel); bConstraint *con = (bConstraint *)con_ptr->data; + /* Ensure called operator does have a context with the expected "constraint" member. */ + ListBase contexts = {NULL}; + bContextStore *previous_context_store = CTX_store_get(C); + if (previous_context_store != NULL) { + BLI_addtail(&contexts, previous_context_store); + } + bContextStore *constraint_context_store = CTX_store_add(&contexts, "constraint", con_ptr); + CTX_store_set(C, constraint_context_store); + PointerRNA props_ptr; wmOperatorType *ot = WM_operatortype_find("CONSTRAINT_OT_move_to_index", false); WM_operator_properties_create_ptr(&props_ptr, ot); @@ -2045,6 +2054,12 @@ static void constraint_reorder(bContext *C, Panel *panel, int new_index) RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0); WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); WM_operator_properties_free(&props_ptr); + + /* Cleanup modified context. */ + CTX_store_set(C, previous_context_store); + if (previous_context_store != constraint_context_store) { + CTX_store_free(constraint_context_store); + } } /** |