Fix: XR action map memory leaks
This fixes two memory leaks related to XR action maps. 1. Freeing of action maps needs to be moved from wm_xr_exit() to wm_xr_runtime_data_free() since the runtime may have already been freed when calling wm_xr_exit(). 2. Action bindings for action map items were not being freed. This was mistakenly left out ofe844e9e8f3
since the patch needed to be updated afterd3d4be1db3
.
This commit is contained in:
parent
a34652d6f8
commit
cb9c0aa7d0
|
@ -115,7 +115,6 @@ bool wm_xr_init(wmWindowManager *wm)
|
|||
void wm_xr_exit(wmWindowManager *wm)
|
||||
{
|
||||
if (wm->xr.runtime != NULL) {
|
||||
WM_xr_actionmaps_clear(wm->xr.runtime);
|
||||
wm_xr_runtime_data_free(&wm->xr.runtime);
|
||||
}
|
||||
if (wm->xr.session_settings.shading.prop) {
|
||||
|
@ -166,6 +165,9 @@ void wm_xr_runtime_data_free(wmXrRuntimeData **runtime)
|
|||
/* Prevent recursive GHOST_XrContextDestroy() call by NULL'ing the context pointer before the
|
||||
* first call, see comment above. */
|
||||
(*runtime)->context = NULL;
|
||||
|
||||
WM_xr_actionmaps_clear(*runtime);
|
||||
|
||||
GHOST_XrContextDestroy(context);
|
||||
}
|
||||
MEM_SAFE_FREE(*runtime);
|
||||
|
|
|
@ -178,6 +178,12 @@ XrActionMapBinding *WM_xr_actionmap_binding_find(XrActionMapItem *ami, const cha
|
|||
* Item in an XR action map, that maps an XR event to an operator, pose, or haptic output.
|
||||
* \{ */
|
||||
|
||||
static void wm_xr_actionmap_item_bindings_clear(XrActionMapItem *ami)
|
||||
{
|
||||
BLI_freelistN(&ami->bindings);
|
||||
ami->selbinding = -1;
|
||||
}
|
||||
|
||||
static void wm_xr_actionmap_item_properties_set(XrActionMapItem *ami)
|
||||
{
|
||||
WM_operator_properties_alloc(&(ami->op_properties_ptr), &(ami->op_properties), ami->op);
|
||||
|
@ -345,10 +351,8 @@ bool WM_xr_actionmap_item_remove(XrActionMap *actionmap, XrActionMapItem *ami)
|
|||
int idx = BLI_findindex(&actionmap->items, ami);
|
||||
|
||||
if (idx != -1) {
|
||||
if (ami->op_properties_ptr) {
|
||||
WM_operator_properties_free(ami->op_properties_ptr);
|
||||
MEM_freeN(ami->op_properties_ptr);
|
||||
}
|
||||
wm_xr_actionmap_item_bindings_clear(ami);
|
||||
wm_xr_actionmap_item_properties_free(ami);
|
||||
BLI_freelinkN(&actionmap->items, ami);
|
||||
|
||||
if (BLI_listbase_is_empty(&actionmap->items)) {
|
||||
|
@ -518,6 +522,7 @@ XrActionMap *WM_xr_actionmap_find(wmXrRuntimeData *runtime, const char *name)
|
|||
void WM_xr_actionmap_clear(XrActionMap *actionmap)
|
||||
{
|
||||
LISTBASE_FOREACH (XrActionMapItem *, ami, &actionmap->items) {
|
||||
wm_xr_actionmap_item_bindings_clear(ami);
|
||||
wm_xr_actionmap_item_properties_free(ami);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue