Skip to content

Commit

Permalink
Bug 769576 - Seg Fault on Editing Scheduled Transaction's Amount
Browse files Browse the repository at this point in the history
The problem being that GValue takes gnc-numerics as boxed values so
qof_object_set needs a gnc-numeric* and qof_object_get a gnc-numeric**.
  • Loading branch information
jralls committed Aug 7, 2016
1 parent 31d13be commit 77bac2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/register/ledger-core/split-register-model-save.c
Expand Up @@ -712,7 +712,7 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
/* amountStr = gnc_numeric_to_string (new_amount); */

formula = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL);
/* If the value can be parsed into a numeric result (without any
/* If the value can be parsed into a numeric result (without any
* further variable definitions), store that numeric value
* additionally in the kvp. Otherwise store a zero numeric
* there.*/
Expand All @@ -725,11 +725,15 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
amount = gnc_numeric_zero();
}
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-credit-numeric", amount,
"sx-credit-formula", formula,
"sx-credit-numeric", &amount,
NULL);
}
else
{
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-credit-formula", formula,
NULL);
g_hash_table_destroy(parser_vars);
parser_vars = g_hash_table_new (g_str_hash, g_str_equal);
}
Expand All @@ -746,11 +750,15 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
amount = gnc_numeric_zero();
}
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-debit-numeric", amount,
"sx-debit-formula", formula,
"sx-debit-numeric", &amount,
NULL);
}
else
{
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-debit-formula", formula,
NULL);
g_hash_table_destroy(parser_vars);
parser_vars = NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions src/register/ledger-core/split-register-model.c
Expand Up @@ -2177,7 +2177,7 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
{
SplitRegister *reg = user_data;
Split *split;
gnc_numeric amount;
gnc_numeric *amount;
const char * cell_name;

split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
Expand All @@ -2196,11 +2196,11 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
qof_instance_get (QOF_INSTANCE (split),
"sx-credit-numeric", &amount,
NULL);
if (gnc_numeric_zero_p (amount))
if (gnc_numeric_zero_p (*amount))
return "";

amount = gnc_numeric_abs (amount);
return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
*amount = gnc_numeric_abs (*amount);
return xaccPrintAmount (*amount, gnc_default_print_info (FALSE));
}

static void
Expand Down

0 comments on commit 77bac2c

Please sign in to comment.