Fix broken handling of constraints reordering with library overrides

Alternative to D13291 (description partially copied from there).

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.

For this to work in a decent way, there needs to be some panel-wide
context that we can restore when executing callbacks outside of the
normal draw context. So similar to uiLayoutSetContextPointer() to set
context on a layout level, this introduces
UI_panel_context_pointer_set() for panel level context (this calls the
former for the current panel root layout as well).

Differential Revision: https://developer.blender.org/D13308
This commit is contained in:
2021-11-23 18:32:23 +01:00
parent fb4851fbbc
commit 792badcfef
8 changed files with 31 additions and 8 deletions

View File

@@ -132,7 +132,7 @@ PointerRNA *modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_
uiBlock *block = uiLayoutGetBlock(panel->layout);
UI_block_lock_set(block, ID_IS_LINKED((Object *)ptr->owner_id), ERROR_LIBDATA_MESSAGE);
uiLayoutSetContextPointer(panel->layout, "modifier", ptr);
UI_panel_context_pointer_set(panel, "modifier", ptr);
return ptr;
}
@@ -304,7 +304,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel)
ModifierData *md = (ModifierData *)ptr->data;
Object *ob = (Object *)ptr->owner_id;
uiLayoutSetContextPointer(panel->layout, "modifier", ptr);
UI_panel_context_pointer_set(panel, "modifier", ptr);
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
Scene *scene = CTX_data_scene(C);