Bug 777949 - Accounts implicitly created in ledger attempt creation twice

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.
This commit is contained in:
John Ralls 2017-03-10 10:54:22 -08:00
parent 97598c4306
commit bc50f3da00

View File

@ -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;
}