mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 797853 - Crash on 'Save As' in MacOS Mojave and Gnucash 4
Check and handle null books throughout GnuCash. Tests are left alone because they should fail if there's no book.
This commit is contained in:
@@ -55,16 +55,19 @@ static QofLogModule log_module = GNC_MOD_ENGINE;
|
||||
const char *
|
||||
gnc_get_num_action (const Transaction *trans, const Split *split)
|
||||
{
|
||||
gboolean num_action = qof_book_use_split_action_for_num_field
|
||||
(qof_session_get_book(gnc_get_current_session ()));
|
||||
|
||||
if (trans && !split)
|
||||
return xaccTransGetNum(trans);
|
||||
if (split && !trans)
|
||||
return xaccSplitGetAction(split);
|
||||
if (trans && split)
|
||||
{
|
||||
if (num_action)
|
||||
QofBook* book = qof_session_get_book(gnc_get_current_session ());
|
||||
if (!book)
|
||||
{
|
||||
PERR("Session has no book but has a transaction or split!");
|
||||
return NULL;
|
||||
}
|
||||
if (qof_book_use_split_action_for_num_field (book))
|
||||
return xaccSplitGetAction(split);
|
||||
else
|
||||
return xaccTransGetNum(trans);
|
||||
|
||||
@@ -509,6 +509,7 @@ qof_book_get_session_dirty_time (const QofBook *book)
|
||||
void
|
||||
qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data)
|
||||
{
|
||||
g_return_if_fail(book);
|
||||
if (book->dirty_cb)
|
||||
PWARN("Already existing callback %p, will be overwritten by %p\n",
|
||||
book->dirty_cb, cb);
|
||||
@@ -1045,7 +1046,7 @@ qof_book_use_trading_accounts (const QofBook *book)
|
||||
gboolean
|
||||
qof_book_use_split_action_for_num_field (const QofBook *book)
|
||||
{
|
||||
g_assert(book);
|
||||
g_return_val_if_fail (book, FALSE);
|
||||
if (!book->cached_num_field_source_isvalid)
|
||||
{
|
||||
// No cached value? Then do the expensive KVP lookup
|
||||
|
||||
Reference in New Issue
Block a user