diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-11-26 12:56:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-11-26 12:58:26 +0300 |
commit | fa1a946d4f3a5e8d010b7eee0a2d93e774fb0009 (patch) | |
tree | 055fe6e350c8ad6adc26957b984c281b2fa42208 /source/blender/windowmanager | |
parent | 1fbca076341919826bf70f7f1a11752223c75c85 (diff) |
Fix memory leak, closing a window didn't free gestures
Exposed by test file in T71718
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 16 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index f7537f5ea9c..44fd9158934 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -623,6 +623,7 @@ void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type); void WM_gesture_end(struct bContext *C, struct wmGesture *gesture); void WM_gestures_remove(struct bContext *C); +void WM_gestures_free_all(struct wmWindow *win); bool WM_gesture_is_modal_first(const struct wmGesture *gesture); /* fileselecting support */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index b79de4370d0..5943e947b41 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -97,10 +97,8 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) return gesture; } -void WM_gesture_end(bContext *C, wmGesture *gesture) +static void wm_gesture_end_with_window(wmWindow *win, wmGesture *gesture) { - wmWindow *win = CTX_wm_window(C); - if (win->tweak == gesture) { win->tweak = NULL; } @@ -110,6 +108,18 @@ void WM_gesture_end(bContext *C, wmGesture *gesture) MEM_freeN(gesture); } +void WM_gesture_end(bContext *C, wmGesture *gesture) +{ + wm_gesture_end_with_window(CTX_wm_window(C), gesture); +} + +void WM_gestures_free_all(wmWindow *win) +{ + while (win->gesture.first) { + wm_gesture_end_with_window(win, win->gesture.first); + } +} + void WM_gestures_remove(bContext *C) { wmWindow *win = CTX_wm_window(C); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 7a5f4bf8367..fb0c60605a7 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -257,6 +257,8 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) MEM_freeN(win->cursor_keymap_status); } + WM_gestures_free_all(win); + wm_event_free_all(win); wm_ghostwindow_destroy(wm, win); |