From bdbaf0301df630cefd3f753c9419646b3f858588 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Oct 2021 08:46:10 +1100 Subject: Fix crash when creating a new window fails Also add operator error report. --- source/blender/windowmanager/intern/wm_window.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_window.c') diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index ce0f710f4c2..89f85caa729 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -49,6 +49,7 @@ #include "BKE_icons.h" #include "BKE_layer.h" #include "BKE_main.h" +#include "BKE_report.h" #include "BKE_screen.h" #include "BKE_workspace.h" @@ -914,7 +915,7 @@ int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op)) +int wm_window_new_exec(bContext *C, wmOperator *op) { wmWindow *win_src = CTX_wm_window(C); ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0); @@ -931,16 +932,23 @@ int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op)) false, WIN_ALIGN_PARENT_CENTER) != NULL); - return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + if (!ok) { + BKE_report(op->reports, RPT_ERROR, "Failed to create window"); + return OPERATOR_CANCELLED; + } + return OPERATOR_FINISHED; } -int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op)) +int wm_window_new_main_exec(bContext *C, wmOperator *op) { wmWindow *win_src = CTX_wm_window(C); bool ok = (wm_window_copy_test(C, win_src, true, false) != NULL); - - return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + if (!ok) { + BKE_report(op->reports, RPT_ERROR, "Failed to create window"); + return OPERATOR_CANCELLED; + } + return OPERATOR_FINISHED; } /* fullscreen operator callback */ -- cgit v1.2.3