gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Sep 21 12:58:19 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/e4d2443c (commit)
via https://github.com/Gnucash/gnucash/commit/35cd0373 (commit)
via https://github.com/Gnucash/gnucash/commit/521b9747 (commit)
via https://github.com/Gnucash/gnucash/commit/69dac5c1 (commit)
from https://github.com/Gnucash/gnucash/commit/60e7497e (commit)
commit e4d2443cf46cf282bffc4242a641435c5dad5ae4
Merge: 60e7497e66 35cd037326
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 21 09:57:49 2024 -0700
Merge Bob Fewell's 'cutpaste' into stable.
commit 35cd037326946742ba985b4fbbd2b6078a4b85ea
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Sat Sep 21 15:33:56 2024 +0100
Bug 798568 - Transaction Copy/Paste problem
When transactions are copied and pasted to the blank transaction on a
register in basic view the wrong split values are displayed. This is
due to the blank split being used for the wrong side of the transaction.
To fix this, record the copied anchor split index and use that to
reference the blank split when the transaction is pasted.
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index dea3c4576b..badd84f50b 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -73,6 +73,7 @@ typedef struct
};
CursorClass cursor_class;
GncGUID leader_guid;
+ gint anchor_split_index;
} ft_fs_store;
static ft_fs_store copied_item = { 0, { NULL } };
@@ -101,6 +102,7 @@ clear_copied_item()
copied_item.ft = NULL;
copied_item.cursor_class = CURSOR_CLASS_NONE;
copied_item.leader_guid = *guid_null();
+ copied_item.anchor_split_index = 0;
}
static void
@@ -828,6 +830,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
}
copied_item.leader_guid = info->default_account;
+ copied_item.anchor_split_index = xaccTransGetSplitIndex (trans, split);
}
}
@@ -1082,7 +1085,11 @@ gnc_split_register_paste_current (SplitRegister* reg)
if (trans == blank_trans)
{
/* In pasting, the blank split is deleted. Pick a new one. */
- blank_split = xaccTransGetSplit (trans, 0);
+ gint anchor_split_index = copied_item.anchor_split_index;
+ if (anchor_split_index > num_splits)
+ anchor_split_index = 0;
+
+ blank_split = xaccTransGetSplit (trans, anchor_split_index);
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
info->blank_split_edited = TRUE;
info->auto_complete = FALSE;
commit 521b9747e0c528b0d661b65c6e444266e26edd1f
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Sat Sep 21 13:09:40 2024 +0100
Move copied_class and copied_leader_guid
Move static copied_class and static copied_leader_guid to be part of
the copied_item structure. This makes it more evident that calling
clear_copied_item needs to be called before copied_item is used.
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index ced855e4c7..dea3c4576b 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -71,11 +71,11 @@ typedef struct
FloatingSplit *fs;
FloatingTxn *ft;
};
+ CursorClass cursor_class;
+ GncGUID leader_guid;
} ft_fs_store;
static ft_fs_store copied_item = { 0, { NULL } };
-static CursorClass copied_class = CURSOR_CLASS_NONE;
-static GncGUID copied_leader_guid;
/** static prototypes *****************************************************/
@@ -99,8 +99,8 @@ clear_copied_item()
copied_item.ftype = 0;
copied_item.fs = NULL;
copied_item.ft = NULL;
- copied_class = CURSOR_CLASS_NONE;
- copied_leader_guid = *guid_null();
+ copied_item.cursor_class = CURSOR_CLASS_NONE;
+ copied_item.leader_guid = *guid_null();
}
static void
@@ -802,7 +802,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
gnc_split_register_save_to_copy_buffer (reg, NULL, new_fs,
use_cut_semantics);
- copied_leader_guid = *guid_null ();
+ copied_item.leader_guid = *guid_null ();
}
}
else
@@ -827,7 +827,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
use_cut_semantics);
}
- copied_leader_guid = info->default_account;
+ copied_item.leader_guid = info->default_account;
}
}
@@ -849,7 +849,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
copied_item.ftype = GNC_TYPE_TRANSACTION;
}
- copied_class = cursor_class;
+ copied_item.cursor_class = cursor_class;
gnc_hook_add_dangler (HOOK_BOOK_CLOSED, clear_copied_item, NULL, NULL);
LEAVE ("%s %s", use_cut_semantics ? "cut" : "copied",
cursor_class == CURSOR_CLASS_SPLIT ? "split" : "transaction");
@@ -917,7 +917,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
ENTER ("reg=%p", reg);
- if (copied_class == CURSOR_CLASS_NONE)
+ if (copied_item.cursor_class == CURSOR_CLASS_NONE)
{
LEAVE ("no copied cursor class");
return;
@@ -965,7 +965,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
"you navigate to a register that shows another "
"side of this same transaction.");
- if (copied_class == CURSOR_CLASS_TRANS)
+ if (copied_item.cursor_class == CURSOR_CLASS_TRANS)
{
/* An entire transaction was copied, but we're just on a split. */
LEAVE ("can't copy trans to split");
@@ -1026,7 +1026,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
int split_index;
int num_splits;
- if (copied_class == CURSOR_CLASS_SPLIT)
+ if (copied_item.cursor_class == CURSOR_CLASS_SPLIT)
{
LEAVE ("can't copy split to transaction");
return;
@@ -1063,7 +1063,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
split_index = xaccTransGetSplitIndex (trans, split);
trans_split_index = xaccTransGetSplitIndex (trans, trans_split);
- copied_leader = xaccAccountLookup (&copied_leader_guid,
+ copied_leader = xaccAccountLookup (&copied_item.leader_guid,
gnc_get_current_book ());
default_account = gnc_split_register_get_default_account (reg);
if (copied_leader && default_account)
commit 69dac5c1a74ce838125181ccbac7b6e61c2898ba
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Sun Sep 15 10:43:43 2024 +0100
Bug 799391 - Transaction Cut/Paste doesn't move the transaction to the target account
Move the clearing of the 'copied_item' to before the setting of the
'copied_leader_guid'. This change is required due to a recent change to
include resetting 'copied_leader_guid' in the 'clear_copied_item'
function.
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index 95e008e3fc..ced855e4c7 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -98,6 +98,7 @@ clear_copied_item()
gnc_float_txn_free (copied_item.ft);
copied_item.ftype = 0;
copied_item.fs = NULL;
+ copied_item.ft = NULL;
copied_class = CURSOR_CLASS_NONE;
copied_leader_guid = *guid_null();
}
@@ -785,6 +786,9 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
return;
}
+ /* unprotect the old object, if any */
+ clear_copied_item();
+
/* Ok, we are now ready to make the copy. */
if (cursor_class == CURSOR_CLASS_SPLIT)
@@ -834,9 +838,6 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
return;
}
- /* unprotect the old object, if any */
- clear_copied_item();
-
if (new_fs)
{
copied_item.fs = new_fs;
Summary of changes:
gnucash/register/ledger-core/split-register.c | 38 ++++++++++++++++-----------
1 file changed, 23 insertions(+), 15 deletions(-)
More information about the gnucash-changes
mailing list