diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 334c745d196..f0abd701618 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3257,7 +3257,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str) double value; if (ui_but_string_eval_number(C, but, str, &value) == false) { - WM_report_banner_show(); + WM_report_banner_show(CTX_wm_manager(C), CTX_wm_window(C)); return false; } diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 04abdc84f14..3112a12b024 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -3558,7 +3558,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) data->escapecancel = true; WM_reportf(RPT_ERROR, "Failed to find '%s'", but->editstr); - WM_report_banner_show(); + WM_report_banner_show(CTX_wm_manager(C), win); } } diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index 1ff1a327ad7..326a96f4836 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -615,7 +615,7 @@ static void renamebutton_cb(bContext *C, void * /*arg1*/, char *oldname) errno = 0; if ((BLI_rename(orgname, newname) != 0) || !BLI_exists(newname)) { WM_reportf(RPT_ERROR, "Could not rename: %s", errno ? strerror(errno) : "unknown error"); - WM_report_banner_show(); + WM_report_banner_show(wm, win); } else { /* If rename is successful, scroll to newly renamed entry. */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index f62ebf282c8..795b588ef80 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -597,8 +597,9 @@ void WM_main_remap_editor_id_reference(const struct IDRemapper *mappings); /* reports */ /** * Show the report in the info header. + * \param win: When NULL, a best-guess is used. */ -void WM_report_banner_show(void); +void WM_report_banner_show(struct wmWindowManager *wm, struct wmWindow *win) ATTR_NONNULL(1); /** * Hide all currently displayed banners and abort their timer. */ diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 4aa0ca96164..7fffd175669 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -882,10 +882,15 @@ static void wm_event_handler_ui_cancel(bContext *C) * Access to #wmWindowManager.reports * \{ */ -void WM_report_banner_show() +void WM_report_banner_show(wmWindowManager *wm, wmWindow *win) { - wmWindowManager *wm = static_cast(G_MAIN->wm.first); - wmWindow *win = wm->winactive ? wm->winactive : static_cast(wm->windows.first); + if (win == nullptr) { + win = wm->winactive; + if (win == nullptr) { + win = static_cast(wm->windows.first); + } + } + ReportList *wm_reports = &wm->reports; /* After adding reports to the global list, reset the report timer. */ @@ -921,7 +926,7 @@ static void wm_add_reports(ReportList *reports) /* Add reports to the global list, otherwise they are not seen. */ BLI_movelisttolist(&wm->reports.list, &reports->list); - WM_report_banner_show(); + WM_report_banner_show(wm, nullptr); } } @@ -2812,7 +2817,7 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C, BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list); /* More hacks, since we meddle with reports, banner display doesn't happen automatic. */ - WM_report_banner_show(); + WM_report_banner_show(CTX_wm_manager(C), CTX_wm_window(C)); CTX_wm_window_set(C, win_prev); CTX_wm_area_set(C, area_prev); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index e716f42be12..e502725f8b8 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -603,29 +603,28 @@ void WM_file_autoexec_init(const char *filepath) } } -void wm_file_read_report(bContext *C, Main *bmain) +void wm_file_read_report(Main *bmain, wmWindow *win) { - ReportList *reports = nullptr; + wmWindowManager *wm = static_cast(bmain->wm.first); + ReportList *reports = &wm->reports; + bool found = false; LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { if (scene->r.engine[0] && BLI_findstring(&R_engines, scene->r.engine, offsetof(RenderEngineType, idname)) == nullptr) { - if (reports == nullptr) { - reports = CTX_wm_reports(C); - } - BKE_reportf(reports, RPT_ERROR, "Engine '%s' not available for scene '%s' (an add-on may need to be installed " "or enabled)", scene->r.engine, scene->id.name + 2); + found = true; } } - if (reports) { + if (found) { if (!G.background) { - WM_report_banner_show(); + WM_report_banner_show(wm, win); } } } @@ -778,7 +777,7 @@ static void wm_file_read_post(bContext *C, const wmFileReadPost_Params *params) /* report any errors. * currently disabled if addons aren't yet loaded */ if (addons_loaded) { - wm_file_read_report(C, bmain); + wm_file_read_report(bmain, static_cast(wm->windows.first)); } if (use_data) { @@ -3739,6 +3738,7 @@ static void wm_block_file_close_discard(bContext *C, void *arg_block, void *arg_ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_data) { const Main *bmain = CTX_data_main(C); + wmWindowManager *wm = static_cast(bmain->wm.first); wmGenericCallback *callback = WM_generic_callback_steal((wmGenericCallback *)arg_data); bool execute_callback = true; @@ -3750,7 +3750,7 @@ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_dat if (ED_image_should_save_modified(bmain)) { ReportList *reports = CTX_wm_reports(C); ED_image_save_all_modified(C, reports); - WM_report_banner_show(); + WM_report_banner_show(wm, win); } else { execute_callback = false; diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 498aca873b0..6fbd52e13b0 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -75,7 +75,7 @@ void wm_homefile_read(struct bContext *C, void wm_homefile_read_post(struct bContext *C, const struct wmFileReadPost_Params *params_file_read_post); -void wm_file_read_report(bContext *C, struct Main *bmain); +void wm_file_read_report(struct Main *bmain, struct wmWindow *win); void wm_close_file_dialog(bContext *C, struct wmGenericCallback *post_action); /** diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c index 0a11805ad03..4eb06840a14 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr.c +++ b/source/blender/windowmanager/xr/intern/wm_xr.c @@ -43,10 +43,12 @@ static void wm_xr_error_handler(const GHOST_XrError *error) { wmXrErrorHandlerData *handler_data = error->customdata; wmWindowManager *wm = handler_data->wm; + wmWindow *root_win = wm->xr.runtime ? wm->xr.runtime->session_root_win : NULL; BKE_reports_clear(&wm->reports); WM_report(RPT_ERROR, error->user_message); - WM_report_banner_show(); + /* Rely on the fallback when `root_win` is NULL. */ + WM_report_banner_show(wm, root_win); if (wm->xr.runtime) { /* Just play safe and destroy the entire runtime data, including context. */