mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fix core dump
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1022 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
133918f416
commit
3dd3a1a1f4
@ -636,6 +636,11 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
|||||||
void
|
void
|
||||||
xaccConfigSplitRegister (SplitRegister *reg, int newtype)
|
xaccConfigSplitRegister (SplitRegister *reg, int newtype)
|
||||||
{
|
{
|
||||||
|
if (!reg) return;
|
||||||
|
|
||||||
|
/* before reconfiguring, clean up any messy state that may be lying about */
|
||||||
|
xaccVerifyCursorPosition (reg->table, -1, -1);
|
||||||
|
|
||||||
reg->type = newtype;
|
reg->type = newtype;
|
||||||
configLayout (reg);
|
configLayout (reg);
|
||||||
configCursors (reg);
|
configCursors (reg);
|
||||||
|
@ -576,14 +576,31 @@ void
|
|||||||
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
|
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
|
||||||
{
|
{
|
||||||
int virt_row, virt_col;
|
int virt_row, virt_col;
|
||||||
|
int do_commit = 0;
|
||||||
|
|
||||||
/* compute the virtual position */
|
if (!table) return;
|
||||||
virt_row = table->locators[phys_row][phys_col]->virt_row;
|
|
||||||
virt_col = table->locators[phys_row][phys_col]->virt_col;
|
|
||||||
|
|
||||||
if ((virt_row != table->current_cursor_virt_row) ||
|
/* Someone may be trying to intentionally invalidate the cursor,
|
||||||
(virt_col != table->current_cursor_virt_col)) {
|
* in which case the physical addresses could be out of bounds.
|
||||||
|
* For example, in order to unmap it in preparation for a reconfig.
|
||||||
|
* So, if the specified location is out of bounds, then
|
||||||
|
* the cursor MUST be moved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((0 > phys_row) || (0 > phys_col)) do_commit = 1;
|
||||||
|
if (phys_row >= table->num_phys_rows) do_commit = 1;
|
||||||
|
if (phys_col >= table->num_phys_cols) do_commit = 1;
|
||||||
|
|
||||||
|
/* Hmm, phys position is valid. Check the virtual position. */
|
||||||
|
if (!do_commit) {
|
||||||
|
virt_row = table->locators[phys_row][phys_col]->virt_row;
|
||||||
|
virt_col = table->locators[phys_row][phys_col]->virt_col;
|
||||||
|
|
||||||
|
if ((virt_row != table->current_cursor_virt_row) ||
|
||||||
|
(virt_col != table->current_cursor_virt_col)) do_commit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_commit) {
|
||||||
/* before leaving the current virtual position,
|
/* before leaving the current virtual position,
|
||||||
* commit any edits that have been accumulated
|
* commit any edits that have been accumulated
|
||||||
* in the cursor */
|
* in the cursor */
|
||||||
|
Loading…
Reference in New Issue
Block a user