gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Tue Sep 1 22:48:39 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/befc4056 (commit)
via https://github.com/Gnucash/gnucash/commit/f503f708 (commit)
via https://github.com/Gnucash/gnucash/commit/094b4ba8 (commit)
via https://github.com/Gnucash/gnucash/commit/fb420652 (commit)
from https://github.com/Gnucash/gnucash/commit/de33d1ef (commit)
commit befc4056ec470f600ac0d7e367686f9f36d29007
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 29 19:30:46 2020 +0800
[gnc-plugin-page-report] use gnc_print_time64
removes the need to store and reset the current QofDateFormat via
qof_date_format_set and qof_date_format_get.
also g_free format_code properly
diff --git a/gnucash/gnome/gnc-plugin-page-report.c b/gnucash/gnome/gnc-plugin-page-report.c
index cb6096290..960d63e61 100644
--- a/gnucash/gnome/gnc-plugin-page-report.c
+++ b/gnucash/gnome/gnc-plugin-page-report.c
@@ -1753,34 +1753,23 @@ static gchar *report_create_jobname(GncPluginPageReportPrivate *priv)
{
// Look up the date format that was chosen in the preferences database
- QofDateFormat date_format_here;
- QofDateFormat date_format_old = qof_date_format_get();
- char *format_code = gnc_prefs_get_string(GNC_PREFS_GROUP_REPORT_PDFEXPORT,
- GNC_PREF_FILENAME_DATE_FMT);
+ QofDateFormat date_format_here = QOF_DATE_FORMAT_ISO;
+ char *format_code = gnc_prefs_get_string (GNC_PREFS_GROUP_REPORT_PDFEXPORT,
+ GNC_PREF_FILENAME_DATE_FMT);
+ const gchar *date_format_string;
if (*format_code == '\0')
{
g_free(format_code);
format_code = g_strdup("locale");
}
- if (gnc_date_string_to_dateformat(format_code, &date_format_here))
- {
- PERR("Incorrect date format code");
- if (format_code != NULL)
- free(format_code);
- }
-
- // To apply this chosen date format, temporarily switch the
- // process-wide default to our chosen date format. Note: It is a
- // totally brain-dead implementation of qof_print_date() to not offer a
- // variation where the QofDateFormat can be passed as an argument.
- // Hrmpf.
- qof_date_format_set(date_format_here);
+ if (gnc_date_string_to_dateformat (format_code, &date_format_here))
+ PERR("Incorrect date format code, using ISO-8601.");
- job_date = qof_print_date( time( NULL ) );
+ date_format_string = qof_date_format_get_string (date_format_here);
- // Restore to the original general date format
- qof_date_format_set(date_format_old);
+ job_date = gnc_print_time64 (gnc_time (NULL), date_format_string);
+ g_free (format_code);
}
commit f503f708f5d547c5607843e618a5bade67583e4b
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 29 19:30:37 2020 +0800
[reports] use gnc-print-time64
removes the need to store and reset the current QofDateFormat via
qof-date-format-set and qof-date-format-get.
also fix test-transaction csv output test.
diff --git a/gnucash/report/reports/standard/balance-forecast.scm b/gnucash/report/reports/standard/balance-forecast.scm
index 94506ecae..603b14cac 100644
--- a/gnucash/report/reports/standard/balance-forecast.scm
+++ b/gnucash/report/reports/standard/balance-forecast.scm
@@ -169,6 +169,7 @@ date point, a projected minimum balance including scheduled transactions."))
price currency
(gnc:accounts-get-commodities accounts #f)
to-date #f #f))
+ (iso-date (qof-date-format-get-string QOF-DATE-FORMAT-ISO))
(accounts-balancelist
(map
(lambda (acc)
@@ -281,11 +282,10 @@ date point, a projected minimum balance including scheduled transactions."))
(gnc:html-chart-set-y-axis-label!
chart (gnc-commodity-get-mnemonic currency))
;; Set series labels
- (let ((old-fmt (qof-date-format-get)))
- (qof-date-format-set QOF-DATE-FORMAT-ISO)
- (gnc:html-chart-set-data-labels!
- chart (map qof-print-date (map cadr intervals)))
- (qof-date-format-set old-fmt))
+ (gnc:html-chart-set-data-labels!
+ chart (map (lambda (data)
+ (gnc-print-time64 (cadr data) iso-date))
+ intervals))
;; Set currency symbol
(gnc:html-chart-set-currency-iso!
diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index 772ba5de2..a8523b2e4 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -26,6 +26,7 @@
(define-module (gnucash reports standard category-barchart))
(use-modules (srfi srfi-1))
(use-modules (srfi srfi-9))
+(use-modules (srfi srfi-26))
(use-modules (ice-9 match))
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
@@ -640,8 +641,7 @@ developing over time"))
(cond
((eq? export-type 'csv)
- (let ((old-fmt (qof-date-format-get)))
- (qof-date-format-set QOF-DATE-FORMAT-ISO)
+ (let ((iso-date (qof-date-format-get-string QOF-DATE-FORMAT-ISO)))
(gnc:html-document-set-export-string
document
(gnc:lists->csv
@@ -665,9 +665,8 @@ developing over time"))
(if (pair? (cdr all-data))
(list (apply gnc:monetary+ row))
'())))
- (map qof-print-date dates-list)
- (apply zip (map cadr all-data))))))
- (qof-date-format-set old-fmt)))))
+ (map (cut gnc-print-time64 <> iso-date) dates-list)
+ (apply zip (map cadr all-data))))))))))
;; else if empty data
(gnc:html-document-add-object!
diff --git a/gnucash/report/reports/standard/net-charts.scm b/gnucash/report/reports/standard/net-charts.scm
index 2c72da5e3..daaa1ad9d 100644
--- a/gnucash/report/reports/standard/net-charts.scm
+++ b/gnucash/report/reports/standard/net-charts.scm
@@ -444,8 +444,7 @@
(cond
((eq? export-type 'csv)
- (let ((old-fmt (qof-date-format-get)))
- (qof-date-format-set QOF-DATE-FORMAT-ISO)
+ (let ((iso-date (qof-date-format-get-string QOF-DATE-FORMAT-ISO)))
(gnc:html-document-set-export-string
document
(gnc:lists->csv
@@ -453,10 +452,9 @@
(map G_ '("Date" "Income" "Expense" "Net Profit"))
(map G_ '("Date" "Assets" "Liabilities" "Net Worth")))
(map list
- (map qof-print-date dates-list)
+ (map (cut gnc-print-time64 <> iso-date) dates-list)
minuend-balances
- subtrahend-balances difference-balances))))
- (qof-date-format-set old-fmt)))))
+ subtrahend-balances difference-balances))))))))
(gnc:html-document-add-object!
document
(gnc:html-make-empty-data-warning
diff --git a/gnucash/report/reports/standard/test/test-transaction.scm b/gnucash/report/reports/standard/test/test-transaction.scm
index 2ef5d71a1..0c9af3682 100644
--- a/gnucash/report/reports/standard/test/test-transaction.scm
+++ b/gnucash/report/reports/standard/test/test-transaction.scm
@@ -885,37 +885,32 @@
(test-end "subtotal table")
(test-begin "csv-export")
- (test-assert "csv output is valid"
- (let ((options (default-testing-options)))
- (set-option! options "Accounts" "Accounts"
- (list bank usd-bank gbp-bank gbp-income income expense))
- (set-option! options "General" "Start Date"
- (cons 'absolute (gnc-dmy2time64 01 01 1969)))
- (set-option! options "General" "End Date"
- (cons 'absolute (gnc-dmy2time64 31 12 1970)))
- (set-option! options "Display" "Subtotal Table" #t)
- (set-option! options "General" "Common Currency" #t)
- (set-option! options "General" "Report Currency" foreign2)
- (set-option! options "General" "Show original currency amount" #t)
- (set-option! options "Sorting" "Primary Key" 'account-name)
- (set-option! options "Sorting" "Primary Subtotal" #t)
- (set-option! options "Sorting" "Secondary Key" 'date)
- (set-option! options "Sorting" "Secondary Subtotal for Date Key" 'monthly)
-
- (let* ((template (gnc:find-report-template trep-uuid))
- (constructor (record-constructor <report>))
- (report (constructor trep-uuid "bar" options #t #t #f #f ""))
- (renderer (gnc:report-template-renderer template)))
- ;; run the renderer, ignore its output. we'll query the csv export.
- (renderer report #:export-type 'csv #:filename "/tmp/export.csv"))
- (let ((call-with-input-file "/tmp/export.csv"))
- (lambda (f)
- (let lp ((c (read-char f)) (out '()))
- (if (eof-object? c)
- (string=?
- "\"from\",\"01/01/69\"\n\"to\",\"12/31/70\"\n\"Amount (GBP)\",2.15\n\"Amount\",3.0"
- (reverse-list->string out))
- (lp (read-char f) (cons c out))))))))
+ (let ((options (default-testing-options)))
+ (set-option! options "Accounts" "Accounts"
+ (list bank usd-bank gbp-bank gbp-income income expense))
+ (set-option! options "General" "Start Date"
+ (cons 'absolute (gnc-dmy2time64 01 01 1969)))
+ (set-option! options "General" "End Date"
+ (cons 'absolute (gnc-dmy2time64 31 12 1970)))
+ (set-option! options "Display" "Subtotal Table" #t)
+ (set-option! options "General" "Common Currency" #t)
+ (set-option! options "General" "Report Currency" foreign2)
+ (set-option! options "General" "Show original currency amount" #t)
+ (set-option! options "Sorting" "Primary Key" 'account-name)
+ (set-option! options "Sorting" "Primary Subtotal" #t)
+ (set-option! options "Sorting" "Secondary Key" 'date)
+ (set-option! options "Sorting" "Secondary Subtotal for Date Key" 'monthly)
+
+ (let* ((template (gnc:find-report-template trep-uuid))
+ (constructor (record-constructor <report>))
+ (report (constructor trep-uuid "bar" options #t #t #f #f ""))
+ (renderer (gnc:report-template-renderer template))
+ (document (renderer report #:export-type 'csv)))
+ (test-assert "csv output has no export error"
+ (not (gnc:html-document-export-error document)))
+ (test-equal "csv output is valid"
+ "\"from\",\"1969-01-01\"\n\"to\",\"1970-12-31\"\n\"Amount (GBP)\",2.15\n\"Amount\",3.0"
+ (gnc:html-document-export-string document))))
(test-end "csv-export")))
(define (reconcile-tests)
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 9d1d9b201..855d2de16 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -2266,20 +2266,19 @@ warning will be removed in GnuCash 5.0"))
(cond
((eq? export-type 'csv)
- (let ((old-date-fmt (qof-date-format-get))
- (dummy (qof-date-format-set QOF-DATE-FORMAT-ISO))
- (infolist
- (list
- (list "from" (qof-print-date begindate))
- (list "to" (qof-print-date enddate)))))
- (qof-date-format-set old-date-fmt)
- (cond
- ((list? csvlist)
+ (cond
+ ((pair? csvlist)
+ (let ((iso-date (qof-date-format-get-string QOF-DATE-FORMAT-ISO)))
(gnc:html-document-set-export-string
- document (lists->csv (append infolist csvlist))))
+ document
+ (lists->csv
+ (cons*
+ `("from" ,(gnc-print-time64 begindate iso-date))
+ `("to" ,(gnc-print-time64 enddate iso-date))
+ csvlist)))))
- (else
- (gnc:html-document-set-export-error document csvlist)))))))))))
+ (else
+ (gnc:html-document-set-export-error document csvlist))))))))))
(gnc:report-finished)
commit 094b4ba8426ef3d97bf7bd6a63e65bb4c51918f0
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 29 20:10:09 2020 +0800
[dialog-file-access] handle close-dialog with <ESC>
diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 18b521090..733cbf95c 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -161,6 +161,7 @@ gnc_ui_file_access_response_cb(GtkDialog *dialog, gint response, GtkDialog *unus
break;
case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
break;
default:
commit fb42065213b58dc80d85f5a2b52f092464619d73
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 29 19:29:03 2020 +0800
g_free strings allocated with gnc_prefs_get_string
gnc_prefs_get_string will return a newly-allocated string. after use,
they must be g_freed.
diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 363ae6fc5..18b521090 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -343,6 +343,7 @@ gnc_ui_file_access (GtkWindow *parent, int type)
faw->starting_dir = g_path_get_dirname( filepath );
g_free ( filepath );
}
+ g_free (last);
}
if (!faw->starting_dir)
faw->starting_dir = gnc_get_default_directory(settings_section);
diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c
index da69b5d88..bf3e3600b 100644
--- a/gnucash/gnome-utils/gnc-plugin-file-history.c
+++ b/gnucash/gnome-utils/gnc-plugin-file-history.c
@@ -256,6 +256,7 @@ gnc_history_remove_file (const char *oldfile)
}
j++;
}
+ g_free (filename);
}
g_free(from);
}
@@ -283,12 +284,18 @@ gboolean gnc_history_test_for_file (const char *oldfile)
filename = gnc_prefs_get_string(GNC_PREFS_GROUP_HISTORY, from);
g_free(from);
- if (filename && (g_utf8_collate(oldfile, filename) == 0))
+ if (!filename)
+ continue;
+
+ if (g_utf8_collate(oldfile, filename) == 0)
{
found = TRUE;
+ g_free (filename);
break;
}
+ g_free (filename);
}
+
return found;
}
@@ -488,7 +495,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
gpointer user_data)
{
GncMainWindow *window;
- const gchar *filename;
+ gchar *filename;
gint index;
ENTER("");
@@ -509,6 +516,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
filename = gnc_prefs_get_string (GNC_PREFS_GROUP_HISTORY, pref);
gnc_history_update_action (window, index, filename);
+ g_free (filename);
gnc_main_window_actions_updated (window);
LEAVE("");
diff --git a/gnucash/gnome/dialog-print-check.c b/gnucash/gnome/dialog-print-check.c
index 6aefd7e46..21a57cd28 100644
--- a/gnucash/gnome/dialog-print-check.c
+++ b/gnucash/gnome/dialog-print-check.c
@@ -609,8 +609,11 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
if (guid == NULL)
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
else if (strcmp(guid, "custom") == 0)
+ {
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
pcd->format_max - 1);
+ g_free (guid);
+ }
else
{
model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
@@ -622,7 +625,9 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
{
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
}
+ g_free (guid);
}
+
active = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_CHECK_POSITION);
/* If the check format used last time no longer exists, then the saved check
Summary of changes:
gnucash/gnome-utils/dialog-file-access.c | 2 +
gnucash/gnome-utils/gnc-plugin-file-history.c | 12 ++++-
gnucash/gnome/dialog-print-check.c | 5 ++
gnucash/gnome/gnc-plugin-page-report.c | 29 ++++-------
.../report/reports/standard/balance-forecast.scm | 10 ++--
.../report/reports/standard/category-barchart.scm | 9 ++--
gnucash/report/reports/standard/net-charts.scm | 8 ++-
.../reports/standard/test/test-transaction.scm | 57 ++++++++++------------
gnucash/report/trep-engine.scm | 23 +++++----
9 files changed, 75 insertions(+), 80 deletions(-)
More information about the gnucash-changes
mailing list