From bc50f3da005d707067a83d74852ad1bcc69f857b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Mar 2017 10:54:22 -0800 Subject: [PATCH] Bug 777949 - Accounts implicitly created in ledger attempt creation twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guard against recursively calling the account doesn’t exist query or creation dialog if one is already in the account creation dialog. The underlying problem is that creating the dialog forces a UI update that in turn sets the cell value and checks for the existence of the account. In basic view the cell being displayed (“transfer”) isn’t the one being changed (“account”) so the account check isn’t invoked, but in multi-split view the “account” cell *is* displayed so the check is invoked again. --- src/register/ledger-core/split-register.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c index 3e4eb74a4e..2e2aebdeee 100644 --- a/src/register/ledger-core/split-register.c +++ b/src/register/ledger-core/split-register.c @@ -1833,6 +1833,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, char *account_name; ComboCell *cell = (ComboCell *) bcell; Account *account; + static gboolean creating_account = FALSE; if (!name || (strlen(name) == 0)) return NULL; @@ -1842,15 +1843,16 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, if (!account) account = gnc_account_lookup_by_code(gnc_get_current_root_account(), name); - if (!account) + if (!account && !creating_account) { /* Ask if they want to create a new one. */ if (!gnc_verify_dialog (gnc_split_register_get_parent (reg), TRUE, missing, name)) return NULL; - + creating_account = TRUE; /* User said yes, they want to create a new account. */ account = gnc_ui_new_accounts_from_name_window (name); + creating_account = FALSE; if (!account) return NULL; }