Fix crash when creating a new window fails

Also add operator error report.
This commit is contained in:
Campbell Barton 2021-10-22 08:46:10 +11:00
parent d9ebe25a0c
commit bdbaf0301d
2 changed files with 19 additions and 7 deletions

View File

@ -647,8 +647,12 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* Exception for background mode, we only need the screen context. */
if (!G.background) {
/* header size depends on DPI, let's verify */
WM_window_set_dpi(win);
/* Called even when creating the ghost window fails in #WM_window_open. */
if (win->ghostwin) {
/* Header size depends on DPI, let's verify. */
WM_window_set_dpi(win);
}
ED_screen_global_areas_refresh(win);

View File

@ -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 */