[Bf-blender-cvs] [f7ca86369da] master: Reports: Add utility to cancel displayed reports

Julian Eisel noreply at git.blender.org
Tue Feb 4 20:11:41 CET 2020


Commit: f7ca86369da89a6726bc9edc9bf4e875b2b43c46
Author: Julian Eisel
Date:   Tue Feb 4 19:51:35 2020 +0100
Branches: master
https://developer.blender.org/rBf7ca86369da89a6726bc9edc9bf4e875b2b43c46

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.

===================================================================

M	source/blender/blenkernel/intern/report.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 5db091e6a43..6b8d7f856ce 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -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;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index d24157a22a6..e128f87f5b7 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -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);
 
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f5970e8fb61..104fbc84306 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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)) {



More information about the Bf-blender-cvs mailing list