Bug 798664 - Result of 'gnucash --nofile' is marked dirty

Don't create a new book in the new-user dialog unless the user says to.
Don't automatically create a new book when retrieving default commodities
because the retrieve might be requested in a context like the Preferences
dialog when there is no book.

Some report tests relied on requesting the default commodity creating
the book, so in those tests ensure that the book is created first.
This commit is contained in:
John Ralls
2022-12-12 11:23:53 -08:00
parent fae5de80d3
commit b4bab92da2
9 changed files with 39 additions and 18 deletions

View File

@@ -565,7 +565,9 @@ gnc_get_current_root_account (void)
gnc_commodity_table *
gnc_get_current_commodities (void)
{
return gnc_commodity_table_get_table (gnc_get_current_book ());
if (gnc_current_session_exist())
return gnc_commodity_table_get_table (gnc_get_current_book ());
return NULL;
}
gchar *
@@ -1170,10 +1172,13 @@ gnc_default_currency_common (gchar *requested_currency,
GNC_COMMODITY_NS_CURRENCY,
requested_currency);
if (gnc_book_use_book_currency (gnc_get_current_book ()))
if (gnc_current_session_exist() &&
gnc_book_use_book_currency (gnc_get_current_book ()))
return gnc_book_get_book_currency (gnc_get_current_book ());
if (gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
if (gnc_current_session_exist() &&
gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
{
mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER);
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
@@ -1185,11 +1190,13 @@ gnc_default_currency_common (gchar *requested_currency,
if (!currency)
currency = gnc_locale_default_currency ();
if (currency)
{
mnemonic = requested_currency;
g_free(mnemonic);
}
return currency;
}