Fix memory leak from builds without XR enabled
Even when built without XR, the window-manager properties could be accessed & created but weren't freed. Exposed by !140098.
This commit is contained in:
@@ -554,6 +554,19 @@ void wm_add_default(Main *bmain, bContext *C)
|
||||
wm_window_make_drawable(wm, win);
|
||||
}
|
||||
|
||||
static void wm_xr_data_free(wmWindowManager *wm)
|
||||
{
|
||||
/* NOTE: this also runs when built without `WITH_XR_OPENXR`.
|
||||
* It's necessary to prevent leaks when XR data is created or loaded into non XR builds.
|
||||
* This can occur when Python reads all properties (see the `bl_rna_paths` test). */
|
||||
|
||||
/* Note that non-runtime data in `wm->xr` is freed as part of freeing the window manager. */
|
||||
if (wm->xr.session_settings.shading.prop) {
|
||||
IDP_FreeProperty(wm->xr.session_settings.shading.prop);
|
||||
wm->xr.session_settings.shading.prop = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
{
|
||||
if (wm->autosavetimer) {
|
||||
@@ -564,6 +577,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
/* May send notifier, so do before freeing notifier queue. */
|
||||
wm_xr_exit(wm);
|
||||
#endif
|
||||
wm_xr_data_free(wm);
|
||||
|
||||
while (wmWindow *win = static_cast<wmWindow *>(BLI_pophead(&wm->windows))) {
|
||||
/* Prevent draw clear to use screen. */
|
||||
|
||||
@@ -134,10 +134,9 @@ void wm_xr_exit(wmWindowManager *wm)
|
||||
if (wm->xr.runtime != nullptr) {
|
||||
wm_xr_runtime_data_free(&wm->xr.runtime);
|
||||
}
|
||||
if (wm->xr.session_settings.shading.prop) {
|
||||
IDP_FreeProperty(wm->xr.session_settings.shading.prop);
|
||||
wm->xr.session_settings.shading.prop = nullptr;
|
||||
}
|
||||
|
||||
/* See #wm_xr_data_free for logic that frees window-manager XR data
|
||||
* that may exist even when built without XR. */
|
||||
}
|
||||
|
||||
bool wm_xr_events_handle(wmWindowManager *wm)
|
||||
|
||||
Reference in New Issue
Block a user