mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Avoid crash from opening transaction in more than one register. Bug #347089.
In any case where we might be opening the transaction and marking it as the pending transaction, check first if it's already open. If it is, we assume that it's being edited by another register. We report the error and abort the action that would have opened the transaction. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14495 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7e2f2b1468
commit
2c6f584b5e
@ -675,19 +675,17 @@ gnc_split_register_auto_completion (SplitRegister *reg,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* now perform the completion */
|
/* now perform the completion */
|
||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
|
||||||
|
|
||||||
info->pending_trans_guid = *xaccTransGetGUID(trans);
|
|
||||||
if ((pending_trans != NULL) && (pending_trans != trans)) {
|
if ((pending_trans != NULL) && (pending_trans != trans)) {
|
||||||
|
if (gnc_split_register_begin_edit_or_warn(info, trans))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (xaccTransIsOpen (pending_trans))
|
if (xaccTransIsOpen (pending_trans))
|
||||||
xaccTransCommitEdit (pending_trans);
|
xaccTransCommitEdit (pending_trans);
|
||||||
else g_assert_not_reached();
|
else g_assert_not_reached();
|
||||||
g_assert(!xaccTransIsOpen(trans));
|
|
||||||
xaccTransBeginEdit(trans);
|
|
||||||
}
|
}
|
||||||
g_assert(xaccTransIsOpen(trans));
|
g_assert(xaccTransIsOpen(trans));
|
||||||
pending_trans = trans;
|
pending_trans = trans;
|
||||||
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE);
|
gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE);
|
||||||
blank_split = NULL;
|
blank_split = NULL;
|
||||||
|
@ -143,6 +143,24 @@ gnc_split_get_amount_denom (Split *split)
|
|||||||
return denom;
|
return denom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns TRUE if begin_edit was aborted */
|
||||||
|
gboolean
|
||||||
|
gnc_split_register_begin_edit_or_warn(SRInfo *info, Transaction *trans)
|
||||||
|
{
|
||||||
|
if (!xaccTransIsOpen(trans)) {
|
||||||
|
xaccTransBeginEdit(trans);
|
||||||
|
/* This is now the pending transaction */
|
||||||
|
info->pending_trans_guid = *xaccTransGetGUID(trans);
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
GtkWidget *parent = NULL;
|
||||||
|
if (info->get_parent)
|
||||||
|
parent = info->get_parent(info->user_data);
|
||||||
|
gnc_error_dialog(parent, "%s", _("This transaction is already being edited in another register. Please finish editing it there first."));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_split_register_expand_current_trans (SplitRegister *reg, gboolean expand)
|
gnc_split_register_expand_current_trans (SplitRegister *reg, gboolean expand)
|
||||||
{
|
{
|
||||||
@ -829,9 +847,8 @@ gnc_split_register_delete_current_split (SplitRegister *reg)
|
|||||||
g_assert(xaccTransIsOpen(trans));
|
g_assert(xaccTransIsOpen(trans));
|
||||||
} else {
|
} else {
|
||||||
g_assert(!pending_trans);
|
g_assert(!pending_trans);
|
||||||
g_assert(!xaccTransIsOpen(trans));
|
if (gnc_split_register_begin_edit_or_warn(info, trans))
|
||||||
xaccTransBeginEdit(trans);
|
return;
|
||||||
info->pending_trans_guid = *xaccTransGetGUID(trans);
|
|
||||||
}
|
}
|
||||||
xaccSplitDestroy (split);
|
xaccSplitDestroy (split);
|
||||||
|
|
||||||
@ -1001,10 +1018,8 @@ gnc_split_register_empty_current_trans_except_split (SplitRegister *reg,
|
|||||||
|
|
||||||
trans = xaccSplitGetParent(split);
|
trans = xaccSplitGetParent(split);
|
||||||
if (!pending) {
|
if (!pending) {
|
||||||
g_assert(!xaccTransIsOpen(trans));
|
if (gnc_split_register_begin_edit_or_warn(info, trans))
|
||||||
xaccTransBeginEdit(trans);
|
return;
|
||||||
/* This is now the pending transaction */
|
|
||||||
info->pending_trans_guid = *xaccTransGetGUID(trans);
|
|
||||||
} else if (pending == trans) {
|
} else if (pending == trans) {
|
||||||
g_assert(xaccTransIsOpen(trans));
|
g_assert(xaccTransIsOpen(trans));
|
||||||
} else g_assert_not_reached();
|
} else g_assert_not_reached();
|
||||||
@ -1351,15 +1366,12 @@ gnc_split_register_save (SplitRegister *reg, gboolean do_commit)
|
|||||||
if (gnc_split_register_handle_exchange (reg, FALSE))
|
if (gnc_split_register_handle_exchange (reg, FALSE))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
|
||||||
|
|
||||||
/* determine whether we should commit the pending transaction */
|
/* determine whether we should commit the pending transaction */
|
||||||
if (pending_trans != trans)
|
if (pending_trans != trans)
|
||||||
{
|
{
|
||||||
// FIXME: How could the pending transaction not be open?
|
// FIXME: How could the pending transaction not be open?
|
||||||
// FIXME: For that matter, how could an open pending
|
// FIXME: For that matter, how could an open pending
|
||||||
// transaction ever not be the current trans?
|
// transaction ever not be the current trans?
|
||||||
info->pending_trans_guid = *xaccTransGetGUID(trans);
|
|
||||||
if (xaccTransIsOpen (pending_trans)) {
|
if (xaccTransIsOpen (pending_trans)) {
|
||||||
g_message("Impossible? commiting pending %p", pending_trans);
|
g_message("Impossible? commiting pending %p", pending_trans);
|
||||||
xaccTransCommitEdit (pending_trans);
|
xaccTransCommitEdit (pending_trans);
|
||||||
@ -1371,10 +1383,13 @@ gnc_split_register_save (SplitRegister *reg, gboolean do_commit)
|
|||||||
g_assert(xaccTransIsOpen(blank_trans));
|
g_assert(xaccTransIsOpen(blank_trans));
|
||||||
} else {
|
} else {
|
||||||
PINFO("beginning edit of trans %p", trans);
|
PINFO("beginning edit of trans %p", trans);
|
||||||
xaccTransBeginEdit (trans);
|
if (gnc_split_register_begin_edit_or_warn(info, trans))
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
pending_trans = trans;
|
pending_trans = trans;
|
||||||
}
|
}
|
||||||
|
g_assert(xaccTransIsOpen(trans));
|
||||||
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
/* If we are committing the blank split, add it to the account now */
|
/* If we are committing the blank split, add it to the account now */
|
||||||
if (trans == blank_trans)
|
if (trans == blank_trans)
|
||||||
|
@ -431,6 +431,10 @@ const char * gnc_split_register_get_credit_string (SplitRegister *reg);
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog);
|
gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog);
|
||||||
|
|
||||||
|
/* returns TRUE if begin_edit was aborted */
|
||||||
|
gboolean
|
||||||
|
gnc_split_register_begin_edit_or_warn(SRInfo *info, Transaction *trans);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user