From 919558854d624f5db40acfa9f5674ac8c94873b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Apr 2021 15:04:59 +1000 Subject: Fix T65064: Keymaps items controlling dynamic enums fail to export Keymap UI and import/export could depend on the current context for dynamic enum's. Use STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID for OperatorProperties. --- source/blender/windowmanager/intern/wm_keymap.c | 9 +++++++++ source/blender/windowmanager/intern/wm_operators.c | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 38d06ea83d3..0a157e63b09 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -80,6 +80,9 @@ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi) kmin->ptr = MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); WM_operator_properties_create(kmin->ptr, kmin->idname); + /* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */ + kmin->ptr->owner_id = NULL; + kmin->properties = IDP_CopyProperty(kmin->properties); kmin->ptr->data = kmin->properties; } @@ -106,6 +109,9 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi) { WM_operator_properties_alloc(&(kmi->ptr), &(kmi->properties), kmi->idname); WM_operator_properties_sanitize(kmi->ptr, 1); + + /* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */ + kmi->ptr->owner_id = NULL; } /** @@ -136,6 +142,9 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi) kmi->ptr->data = kmi->properties; } WM_operator_properties_sanitize(kmi->ptr, 1); + + /* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */ + kmi->ptr->owner_id = NULL; } } else { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 84c16999c1b..9499ac56932 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -583,7 +583,8 @@ char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, i void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot) { - RNA_pointer_create(NULL, ot->srna, NULL, ptr); + /* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */ + RNA_pointer_create(G_MAIN->wm.first, ot->srna, NULL, ptr); } void WM_operator_properties_create(PointerRNA *ptr, const char *opstring) @@ -594,7 +595,8 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring) WM_operator_properties_create_ptr(ptr, ot); } else { - RNA_pointer_create(NULL, &RNA_OperatorProperties, NULL, ptr); + /* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */ + RNA_pointer_create(G_MAIN->wm.first, &RNA_OperatorProperties, NULL, ptr); } } -- cgit v1.2.3