From 818c7dc797c4019bc7a2fc1a1207938b4b283fad Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 27 Apr 2024 19:15:41 +0800 Subject: [PATCH] [gnc-report.cpp] hide gnc_reports impl, expose gnc_reports_foreach Instead of retrieving the GHashTable and iterating through the key/values, expose gnc_reports_foreach which does the same job. --- gnucash/gnome/dialog-report-style-sheet.cpp | 6 +----- gnucash/report/gnc-report.cpp | 7 ++++--- gnucash/report/gnc-report.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gnucash/gnome/dialog-report-style-sheet.cpp b/gnucash/gnome/dialog-report-style-sheet.cpp index 135228bc91e..beda8e548d2 100644 --- a/gnucash/gnome/dialog-report-style-sheet.cpp +++ b/gnucash/gnome/dialog-report-style-sheet.cpp @@ -110,13 +110,9 @@ gnc_style_sheet_options_apply_cb (GncOptionsDialog * propertybox, gpointer user_data) { ss_info * ssi = (ss_info *)user_data; - GHashTable *reports = NULL; GList *results = NULL, *iter; - /* FIXME: shouldn't be global */ - reports = gnc_reports_get_global (); - if (reports) - g_hash_table_foreach (reports, dirty_same_stylesheet, ssi->stylesheet); + gnc_reports_foreach (dirty_same_stylesheet, ssi->stylesheet); results = gnc_option_db_commit (ssi->odb); for (iter = results; iter; iter = iter->next) diff --git a/gnucash/report/gnc-report.cpp b/gnucash/report/gnc-report.cpp index 0e2ac187726..39742f3f67c 100644 --- a/gnucash/report/gnc-report.cpp +++ b/gnucash/report/gnc-report.cpp @@ -200,11 +200,12 @@ gnc_reports_flush_global(void) g_hash_table_foreach_remove(reports, yes_remove, NULL); } -GHashTable * -gnc_reports_get_global(void) +void +gnc_reports_foreach (GHFunc func, gpointer user_data) { gnc_report_init_table(); - return reports; + if (reports) + g_hash_table_foreach (reports, func, user_data); } gboolean diff --git a/gnucash/report/gnc-report.h b/gnucash/report/gnc-report.h index b227616c6be..0b517eeeff4 100644 --- a/gnucash/report/gnc-report.h +++ b/gnucash/report/gnc-report.h @@ -66,7 +66,7 @@ gint gnc_report_add(SCM report); void gnc_reports_flush_global(void); -GHashTable* gnc_reports_get_global(void); +void gnc_reports_foreach (GHFunc func, gpointer user_data); gchar* gnc_get_default_report_font_family(void);