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
@ -3000,6 +3000,7 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
||||
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 prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
|
||||
SCM scm_result;
|
||||
|
||||
QIFImportWindow * wind = user_data;
|
||||
GncPluginPage *page;
|
||||
@ -3020,11 +3021,14 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
||||
gnc_resume_gui_refresh();
|
||||
|
||||
/* 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,
|
||||
wind->memo_map_info, wind->security_hash,
|
||||
wind->security_prefs),
|
||||
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. */
|
||||
gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
|
||||
|
@ -265,20 +265,23 @@
|
||||
;; file. This only gets called when the user clicks the Apply
|
||||
;; button in the druid, so any new mappings will be lost if the
|
||||
;; 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
|
||||
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")
|
||||
|
||||
;; This procedure does all the work. We'll define it, then call it safely.
|
||||
(define (private-save)
|
||||
(with-output-to-file (gnc-build-dotgnucash-path "qif-accounts-map")
|
||||
(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)
|
||||
@ -302,7 +305,11 @@
|
||||
(display ";;; GnuCash separator used in these mappings")
|
||||
(newline)
|
||||
(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