From e240025276648218c19d3fb7dbd5af92253b7718 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 1 Sep 2016 16:25:42 +0200 Subject: Fix T49199: Combination of dialog + wm.open_mainfile causes crash Issue was that the wm.open_mainfile OP caused all handlers to be removed and since rB45592291 cancelled (which is correct in general), the menu that triggered the OP should not be cancelled though. Not sure if this is a nice fix or not, it's however the safest fix I found. A different fix would be to call UI_popup_block_close before WM_operator_call_ex (in dialog_exec_cb), but not sure how safe this is and want to further investigate if it makes other hacks/fixes redundant. There's still a crash with --debug-memory that confused the heck out of me (since I always have --debug-memory enabled), but I'll commit fix for that separately. --- source/blender/windowmanager/intern/wm_operators.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fcdab746d57..8918b6bb1b8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1375,6 +1375,10 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) wmOpPopUp *data = arg1; uiBlock *block = arg2; + /* Explicitly set UI_RETURN_OK flag, otherwise the menu might be cancelled + * in case WM_operator_call_ex exits/reloads the current file (T49199). */ + UI_popup_menu_retval_set(block, UI_RETURN_OK, true); + WM_operator_call_ex(C, data->op, true); /* let execute handle freeing it */ -- cgit v1.2.3 From 96dd1943afc4f08e4befb44602a3c621a446c678 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 1 Sep 2016 16:55:01 +0200 Subject: Fix crash calling wm.open_mainfile from menu with --debug-memory enabled Didn't do any bisecting, but guess it's caused rBb54e95a5c8dcb7 (2.74 is fine, 2.75 isn't). I think this fix makes some other hacks redundant but need to check details (will do when we're back to bcon1 to avoid regressions). --- source/blender/windowmanager/intern/wm_operators.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8918b6bb1b8..0c137221856 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1369,9 +1369,6 @@ typedef struct wmOpPopUp { /* Only invoked by OK button in popups created with wm_block_dialog_create() */ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) { - wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *win = CTX_wm_window(C); - wmOpPopUp *data = arg1; uiBlock *block = arg2; @@ -1388,8 +1385,18 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) /* in this case, wm_operator_ui_popup_cancel wont run */ MEM_freeN(data); + /* get context data *after* WM_operator_call_ex which might have closed the current file and changed context */ + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + /* check window before 'block->handle' incase the - * popup execution closed the window and freed the block. see T44688. */ + * popup execution closed the window and freed the block. see T44688. + */ + /* Post 2.78 TODO: Check if this fix and others related to T44688 are still + * needed or can be improved now that requesting context data has been corrected + * (see above). We're close to release so not a good time for experiments. + * -- Julian + */ if (BLI_findindex(&wm->windows, win) != -1) { UI_popup_block_close(C, win, block); } -- cgit v1.2.3