diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-06-08 08:57:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-06-08 09:02:57 +0300 |
commit | b54e95a5c8dcb7eae1059af107a7cdfa028d7e2e (patch) | |
tree | 9f2f977f16f8dbd52d490f0acbba4b4a53a1b155 | |
parent | 22a4fcb146c73ec922d959a33774f5a83cad4adb (diff) |
Alternative fix copying windows from popup dialogs
It could still crash if the window was freed and another was activated. see T44688.
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 15 |
3 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b400e254f8..ef0a57fed75 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -401,7 +401,7 @@ void UI_popup_block_invoke_ex(struct bContext *C, uiBlockCreateFunc func, void * void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg); /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */ -void UI_popup_block_close(struct bContext *C, uiBlock *block); +void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block); /* Blocks * diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9835f0885b6..da2852c71d1 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -3049,16 +3049,11 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int } #endif -void UI_popup_block_close(bContext *C, uiBlock *block) +void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) { - wmWindow *win = CTX_wm_window(C); - - /* check window before 'block->handle' incase the - * popup execution closed the window and freed the block. see T44688. */ - /* if loading new .blend while popup is open, window will be NULL */ - if (win) { - if (block->handle) { + if (block->handle) { + if (win) { UI_popup_handlers_remove(&win->modalhandlers, block->handle); ui_popup_block_free(C, block->handle); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3c23f7367fb..041ef6f8282 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1554,6 +1554,9 @@ 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; @@ -1566,7 +1569,11 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) /* in this case, wm_operator_ui_popup_cancel wont run */ MEM_freeN(data); - UI_popup_block_close(C, block); + /* check window before 'block->handle' incase the + * popup execution closed the window and freed the block. see T44688. */ + if (BLI_findindex(&wm->windows, win) != -1) { + UI_popup_block_close(C, win, block); + } } static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) @@ -1840,7 +1847,8 @@ static void WM_OT_operator_defaults(wmOperatorType *ot) static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg)) { - UI_popup_block_close(C, arg_block); + wmWindow *win = CTX_wm_window(C); + UI_popup_block_close(C, win, arg_block); } static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unused); @@ -1852,7 +1860,8 @@ static void wm_block_splash_refreshmenu(bContext *UNUSED(C), void *UNUSED(arg_bl /* ugh, causes crashes in other buttons, disabling for now until * a better fix */ #if 0 - UI_popup_block_close(C, arg_block); + wmWindow *win = CTX_wm_window(C); + UI_popup_block_close(C, win, arg_block); UI_popup_block_invoke(C, wm_block_create_splash, NULL); #endif } |