mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #548891: QIF Import: Prevent crashing when the mapping preferences can't be saved.
BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17477 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a8820e769b
commit
fd987c0b3d
@ -2997,9 +2997,10 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
|||||||
gpointer arg1,
|
gpointer arg1,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
SCM save_map_prefs = scm_c_eval_string("qif-import:save-map-prefs");
|
SCM save_map_prefs = scm_c_eval_string("qif-import:save-map-prefs");
|
||||||
SCM cat_and_merge = scm_c_eval_string("gnc:account-tree-catenate-and-merge");
|
SCM cat_and_merge = scm_c_eval_string("gnc:account-tree-catenate-and-merge");
|
||||||
SCM prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
|
SCM prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
|
||||||
|
SCM scm_result;
|
||||||
|
|
||||||
QIFImportWindow * wind = user_data;
|
QIFImportWindow * wind = user_data;
|
||||||
GncPluginPage *page;
|
GncPluginPage *page;
|
||||||
@ -3020,11 +3021,14 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
|||||||
gnc_resume_gui_refresh();
|
gnc_resume_gui_refresh();
|
||||||
|
|
||||||
/* Save the user's mapping preferences. */
|
/* Save the user's mapping preferences. */
|
||||||
scm_apply(save_map_prefs,
|
scm_result = scm_apply(save_map_prefs,
|
||||||
SCM_LIST5(wind->acct_map_info, wind->cat_map_info,
|
SCM_LIST5(wind->acct_map_info, wind->cat_map_info,
|
||||||
wind->memo_map_info, wind->security_hash,
|
wind->memo_map_info, wind->security_hash,
|
||||||
wind->security_prefs),
|
wind->security_prefs),
|
||||||
SCM_EOL);
|
SCM_EOL);
|
||||||
|
if (scm_result == SCM_BOOL_F)
|
||||||
|
gnc_warning_dialog(wind->window,
|
||||||
|
_("GnuCash was unable to save your mapping preferences."));
|
||||||
|
|
||||||
/* Open an account tab in the main window if one doesn't exist already. */
|
/* Open an account tab in the main window if one doesn't exist already. */
|
||||||
gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
|
gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
|
||||||
|
@ -265,44 +265,51 @@
|
|||||||
;; file. This only gets called when the user clicks the Apply
|
;; file. This only gets called when the user clicks the Apply
|
||||||
;; button in the druid, so any new mappings will be lost if the
|
;; button in the druid, so any new mappings will be lost if the
|
||||||
;; user cancels the import instead.
|
;; user cancels the import instead.
|
||||||
|
;;
|
||||||
|
;; Returns #t upon success or #f on failure.
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define (qif-import:save-map-prefs acct-map cat-map memo-map
|
(define (qif-import:save-map-prefs acct-map cat-map memo-map
|
||||||
security-map security-prefs)
|
security-map security-prefs)
|
||||||
(let* ((pref-filename (gnc-build-dotgnucash-path "qif-accounts-map")))
|
|
||||||
;; does the file exist? if not, create it; in either case,
|
|
||||||
;; make sure it's a directory and we have write and execute
|
|
||||||
;; permission.
|
|
||||||
(with-output-to-file pref-filename
|
|
||||||
(lambda ()
|
|
||||||
(display ";;; qif-accounts-map\n")
|
|
||||||
(display ";;; Automatically generated by GnuCash. DO NOT EDIT.\n")
|
|
||||||
(display ";;; (Unless you really, really want to.)\n")
|
|
||||||
|
|
||||||
(display ";;; Map QIF accounts to GnuCash accounts")
|
;; This procedure does all the work. We'll define it, then call it safely.
|
||||||
(newline)
|
(define (private-save)
|
||||||
(qif-import:write-map acct-map)
|
(with-output-to-file (gnc-build-dotgnucash-path "qif-accounts-map")
|
||||||
(newline)
|
(lambda ()
|
||||||
|
(display ";;; qif-accounts-map")
|
||||||
|
(newline)
|
||||||
|
(display ";;; Automatically generated by GnuCash. DO NOT EDIT.")
|
||||||
|
(newline)
|
||||||
|
(display ";;; (Unless you really, really want to.)")
|
||||||
|
(newline)
|
||||||
|
(display ";;; Map QIF accounts to GnuCash accounts")
|
||||||
|
(newline)
|
||||||
|
(qif-import:write-map acct-map)
|
||||||
|
(newline)
|
||||||
|
|
||||||
(display ";;; Map QIF categories to GnuCash accounts")
|
(display ";;; Map QIF categories to GnuCash accounts")
|
||||||
(newline)
|
(newline)
|
||||||
(qif-import:write-map cat-map)
|
(qif-import:write-map cat-map)
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
(display ";;; Map QIF payee/memo to GnuCash accounts")
|
(display ";;; Map QIF payee/memo to GnuCash accounts")
|
||||||
(newline)
|
(newline)
|
||||||
(qif-import:write-map memo-map)
|
(qif-import:write-map memo-map)
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
(display ";;; Map QIF security names to GnuCash commodities")
|
(display ";;; Map QIF security names to GnuCash commodities")
|
||||||
(newline)
|
(newline)
|
||||||
(qif-import:write-securities security-map security-prefs)
|
(qif-import:write-securities security-map security-prefs)
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
(display ";;; GnuCash separator used in these mappings")
|
(display ";;; GnuCash separator used in these mappings")
|
||||||
(newline)
|
(newline)
|
||||||
(write (gnc-get-account-separator-string))
|
(write (gnc-get-account-separator-string))
|
||||||
(newline)))))
|
(newline)))
|
||||||
|
#t)
|
||||||
|
|
||||||
|
;; Safely save the file.
|
||||||
|
(gnc:backtrace-if-exception private-save))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
Loading…
Reference in New Issue
Block a user