Reports: Add utility to cancel displayed reports

Sebastián Barschkis needs something like this to fix an issue, so he
asked me to add this to the release branch. It's unused for now.
This commit is contained in:
Julian Eisel 2020-02-04 19:51:35 +01:00
parent c19112d755
commit f7ca86369d
3 changed files with 16 additions and 0 deletions

View File

@ -76,6 +76,11 @@ void BKE_reports_init(ReportList *reports, int flag)
reports->flag = flag;
}
/**
* Only frees the list \a reports.
* To make displayed reports disappear, either remove window-manager reports
* (wmWindowManager.reports, or CTX_wm_reports()), or use #WM_report_banners_cancel().
*/
void BKE_reports_clear(ReportList *reports)
{
Report *report, *report_next;

View File

@ -309,6 +309,7 @@ void WM_main_remap_editor_id_reference(struct ID *old_id, struct ID *new_id);
/* reports */
void WM_report_banner_show(void);
void WM_report_banners_cancel(struct Main *bmain);
void WM_report(ReportType type, const char *message);
void WM_reportf(ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3);

View File

@ -861,6 +861,16 @@ void WM_report_banner_show(void)
wm_reports->reporttimer->customdata = rti;
}
/**
* Hide all currently displayed banners and abort their timer.
*/
void WM_report_banners_cancel(Main *bmain)
{
wmWindowManager *wm = bmain->wm.first;
BKE_reports_clear(&wm->reports);
WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
}
bool WM_event_is_last_mousemove(const wmEvent *event)
{
while ((event = event->next)) {