Bug 769576 - Seg Fault on Editing Scheduled Transaction's Amount

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**.
This commit is contained in:
John Ralls 2016-08-06 17:37:32 -07:00
parent 31d13beeb1
commit 77bac2c2ff
2 changed files with 15 additions and 7 deletions

View File

@ -712,7 +712,7 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
/* amountStr = gnc_numeric_to_string (new_amount); */ /* amountStr = gnc_numeric_to_string (new_amount); */
formula = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL); 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 * further variable definitions), store that numeric value
* additionally in the kvp. Otherwise store a zero numeric * additionally in the kvp. Otherwise store a zero numeric
* there.*/ * there.*/
@ -725,11 +725,15 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
amount = gnc_numeric_zero(); amount = gnc_numeric_zero();
} }
qof_instance_set (QOF_INSTANCE (sd->split), qof_instance_set (QOF_INSTANCE (sd->split),
"sx-credit-numeric", amount, "sx-credit-formula", formula,
"sx-credit-numeric", &amount,
NULL); NULL);
} }
else else
{ {
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-credit-formula", formula,
NULL);
g_hash_table_destroy(parser_vars); g_hash_table_destroy(parser_vars);
parser_vars = g_hash_table_new (g_str_hash, g_str_equal); parser_vars = g_hash_table_new (g_str_hash, g_str_equal);
} }
@ -746,11 +750,15 @@ gnc_template_register_save_debcred_cell (BasicCell * cell,
amount = gnc_numeric_zero(); amount = gnc_numeric_zero();
} }
qof_instance_set (QOF_INSTANCE (sd->split), qof_instance_set (QOF_INSTANCE (sd->split),
"sx-debit-numeric", amount, "sx-debit-formula", formula,
"sx-debit-numeric", &amount,
NULL); NULL);
} }
else else
{ {
qof_instance_set (QOF_INSTANCE (sd->split),
"sx-debit-formula", formula,
NULL);
g_hash_table_destroy(parser_vars); g_hash_table_destroy(parser_vars);
parser_vars = NULL; parser_vars = NULL;
} }

View File

@ -2177,7 +2177,7 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
{ {
SplitRegister *reg = user_data; SplitRegister *reg = user_data;
Split *split; Split *split;
gnc_numeric amount; gnc_numeric *amount;
const char * cell_name; const char * cell_name;
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc); split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
@ -2196,11 +2196,11 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
qof_instance_get (QOF_INSTANCE (split), qof_instance_get (QOF_INSTANCE (split),
"sx-credit-numeric", &amount, "sx-credit-numeric", &amount,
NULL); NULL);
if (gnc_numeric_zero_p (amount)) if (gnc_numeric_zero_p (*amount))
return ""; return "";
amount = gnc_numeric_abs (amount); *amount = gnc_numeric_abs (*amount);
return xaccPrintAmount (amount, gnc_default_print_info (FALSE)); return xaccPrintAmount (*amount, gnc_default_print_info (FALSE));
} }
static void static void