diff options
author | Campbell Barton <campbell@blender.org> | 2022-05-10 15:56:22 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-05-10 15:56:22 +0300 |
commit | 9173dd24adc7775b76840912b76ed37828938829 (patch) | |
tree | a602d42b5192e0d094323dfe060d43ecad08c309 /source/blender/windowmanager | |
parent | 502c3d6c21e9ca5947f525dcd3870e795c1b2fc6 (diff) |
Fix for crash opening the file selector multiple times
This is part of a fix for T88570, where the file selector would crash
when activated multiple times.
Calling save multiple times would free the operator, leaving a dangling
pointer which was used when panels were visible that accessed the
"active_operator".
Reviewed By: Severin
Ref D14905
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d375fb04744..082e6443ba2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -101,6 +101,7 @@ static int wm_operator_call_internal(bContext *C, static bool wm_operator_check_locked_interface(bContext *C, wmOperatorType *ot); static wmEvent *wm_event_add_mousemove_to_head(wmWindow *win); +static void wm_operator_free_for_fileselect(wmOperator *file_operator); /* -------------------------------------------------------------------- */ /** \name Event Management @@ -2036,7 +2037,13 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) } WM_cursor_grab_disable(win, NULL); - WM_operator_free(handler->op); + + if (handler->is_fileselect) { + wm_operator_free_for_fileselect(handler->op); + } + else { + WM_operator_free(handler->op); + } } } else if (handler_base->type == WM_HANDLER_TYPE_UI) { @@ -2473,6 +2480,22 @@ static int wm_handler_operator_call(bContext *C, return WM_HANDLER_BREAK; } +static void wm_operator_free_for_fileselect(wmOperator *file_operator) +{ + LISTBASE_FOREACH (bScreen *, screen, &G_MAIN->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype == SPACE_FILE) { + SpaceFile *sfile = area->spacedata.first; + if (sfile->op == file_operator) { + sfile->op = NULL; + } + } + } + } + + WM_operator_free(file_operator); +} + /** * File-select handlers are only in the window queue, * so it's safe to switch screens or area types. @@ -2668,7 +2691,7 @@ static int wm_handler_fileselect_do(bContext *C, } if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { - WM_operator_free(handler->op); + wm_operator_free_for_fileselect(handler->op); } } else { @@ -2683,8 +2706,7 @@ static int wm_handler_fileselect_do(bContext *C, wm->op_undo_depth--; } } - - WM_operator_free(handler->op); + wm_operator_free_for_fileselect(handler->op); } CTX_wm_area_set(C, NULL); |