Fix memory leak, closing a window didn't free gestures

Exposed by test file in T71718
This commit is contained in:
Campbell Barton 2019-11-26 20:56:08 +11:00
parent 1fbca07634
commit fa1a946d4f
3 changed files with 16 additions and 3 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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);