Fix incorrect copying of XR action map items
After using MEM_dupallocN() on the original item, the bindings ListBase for the new item needs to be cleared and each binding copied separately.
This commit is contained in:
parent
30cebf5747
commit
894269ad12
|
@ -115,7 +115,6 @@ void WM_xr_actionmap_binding_ensure_unique(XrActionMapItem *ami, XrActionMapBind
|
|||
static XrActionMapBinding *wm_xr_actionmap_binding_copy(XrActionMapBinding *amb_src)
|
||||
{
|
||||
XrActionMapBinding *amb_dst = MEM_dupallocN(amb_src);
|
||||
|
||||
amb_dst->prev = amb_dst->next = NULL;
|
||||
|
||||
return amb_dst;
|
||||
|
@ -298,25 +297,29 @@ void WM_xr_actionmap_item_ensure_unique(XrActionMap *actionmap, XrActionMapItem
|
|||
BLI_strncpy(ami->name, name, MAX_NAME);
|
||||
}
|
||||
|
||||
static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami)
|
||||
static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src)
|
||||
{
|
||||
XrActionMapItem *amin = MEM_dupallocN(ami);
|
||||
XrActionMapItem *ami_dst = MEM_dupallocN(ami_src);
|
||||
ami_dst->prev = ami_dst->next = NULL;
|
||||
|
||||
amin->prev = amin->next = NULL;
|
||||
BLI_listbase_clear(&ami_dst->bindings);
|
||||
LISTBASE_FOREACH (XrActionMapBinding *, amb, &ami_src->bindings) {
|
||||
XrActionMapBinding *amb_new = wm_xr_actionmap_binding_copy(amb);
|
||||
BLI_addtail(&ami_dst->bindings, amb_new);
|
||||
}
|
||||
|
||||
if (amin->op_properties) {
|
||||
amin->op_properties_ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
|
||||
WM_operator_properties_create(amin->op_properties_ptr, amin->op);
|
||||
|
||||
amin->op_properties = IDP_CopyProperty(amin->op_properties);
|
||||
amin->op_properties_ptr->data = amin->op_properties;
|
||||
if (ami_dst->op_properties) {
|
||||
ami_dst->op_properties_ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
|
||||
WM_operator_properties_create(ami_dst->op_properties_ptr, ami_dst->op);
|
||||
ami_dst->op_properties = IDP_CopyProperty(ami_src->op_properties);
|
||||
ami_dst->op_properties_ptr->data = ami_dst->op_properties;
|
||||
}
|
||||
else {
|
||||
amin->op_properties = NULL;
|
||||
amin->op_properties_ptr = NULL;
|
||||
ami_dst->op_properties = NULL;
|
||||
ami_dst->op_properties_ptr = NULL;
|
||||
}
|
||||
|
||||
return amin;
|
||||
return ami_dst;
|
||||
}
|
||||
|
||||
XrActionMapItem *WM_xr_actionmap_item_add_copy(XrActionMap *actionmap, XrActionMapItem *ami_src)
|
||||
|
@ -431,10 +434,9 @@ void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *action
|
|||
static XrActionMap *wm_xr_actionmap_copy(XrActionMap *am_src)
|
||||
{
|
||||
XrActionMap *am_dst = MEM_dupallocN(am_src);
|
||||
|
||||
am_dst->prev = am_dst->next = NULL;
|
||||
BLI_listbase_clear(&am_dst->items);
|
||||
|
||||
BLI_listbase_clear(&am_dst->items);
|
||||
LISTBASE_FOREACH (XrActionMapItem *, ami, &am_src->items) {
|
||||
XrActionMapItem *ami_new = wm_xr_actionmap_item_copy(ami);
|
||||
BLI_addtail(&am_dst->items, ami_new);
|
||||
|
|
Loading…
Reference in New Issue