diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-02-24 17:57:29 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-02-24 17:57:29 +0300 |
commit | 7972785d7b90771f50534fe3e1101d8adb615fa3 (patch) | |
tree | 0880e1531a3809d6c1ec26eda638c22659b4fe73 /source/blender/windowmanager/intern | |
parent | 6b6469a2e552e1454cb09987d931cc5e72a99fdf (diff) |
PyAPI: Fix memory leak of parameters used for python 'draw_callbacks'
When closing the blender, while the callbacks are removed, the
reference count of the object used as `customdata` is not decremented.
This commit adds two functions that correctly release the
python `draw_callbacks` before releasing all `draw_callbacks`.
Differential Revision: https://developer.blender.org/D10478
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 549b59e9e1d..b43357b1462 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -595,6 +595,9 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) WM_msgbus_destroy(wm->message_bus); } +#ifdef WITH_PYTHON + BPY_callback_wm_free(wm); +#endif BLI_freelistN(&wm->paintcursors); WM_drag_free_list(&wm->drags); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 297575e8dff..bab8359472f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2056,6 +2056,22 @@ bool WM_paint_cursor_end(wmPaintCursor *handle) return false; } +void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void (*free)(void *)) +{ + wmPaintCursor *pc = wm->paintcursors.first; + while (pc) { + wmPaintCursor *pc_next = pc->next; + if (pc->draw == draw_fn) { + if (free) { + free(pc->customdata); + } + BLI_remlink(&wm->paintcursors, pc); + MEM_freeN(pc); + } + pc = pc_next; + } +} + /** \} */ /* -------------------------------------------------------------------- */ |