diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 10:16:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 10:16:49 +0400 |
commit | 761b380b841e5660356616a0e0b46880e5a01c4e (patch) | |
tree | 51b0f10430e1262d6700ec84daf75e35978a33cc /source/blender/windowmanager/intern/wm.c | |
parent | 3eb41c7a5f96c6a7199a81e8a73b1da3053806ea (diff) |
fix [#33841] Disabling and re-enabling live addon crashes blender (modal/draw handler)
Diffstat (limited to 'source/blender/windowmanager/intern/wm.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 53e67e91bd2..a01f7301ec2 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -149,6 +149,31 @@ void WM_operator_stack_clear(wmWindowManager *wm) WM_main_add_notifier(NC_WM | ND_HISTORY, NULL); } +/** + * This function is needed in the case when an addon id disabled + * while a modal operator it defined is running. + */ +void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot) +{ + wmWindow *win; + for (win = wm->windows.first; win; win = win->next) { + ListBase *lb[2] = {&win->handlers, &win->modalhandlers}; + wmEventHandler *handler; + int i; + + for (i = 0; i < 2; i++) { + for (handler = lb[i]->first; handler; handler = handler->next) { + if (handler->op && handler->op->type == ot) { + /* don't run op->cancel because it needs the context, + * assume whoever unregisters the operator will cleanup */ + handler->flag |= WM_HANDLER_DO_FREE; + WM_operator_free(handler->op); + handler->op = NULL; + } + } + } + } +} /* ************ uiListType handling ************** */ |