Bug 799108 - "Since Last Run" crashes if there are any errors creating a scheduled transaction

Pass a creation_errors list to gnc_sx_instance_model_effect_change() so
that errors creating SX can be stored, and then display them.
This commit is contained in:
Simon Arlott 2023-10-21 12:04:00 +01:00
parent 4592530318
commit 90c9aaf4cb
No known key found for this signature in database
GPG Key ID: DF001BFD83E75990
4 changed files with 19 additions and 6 deletions

View File

@ -759,8 +759,8 @@ gnc_sx_slr_tree_model_adapter_new (GncSxInstanceModel *instances)
return rtn; return rtn;
} }
static void void
creation_error_dialog (GList **creation_errors) gnc_ui_sx_creation_error_dialog (GList **creation_errors)
{ {
GtkWidget *dialog = NULL; GtkWidget *dialog = NULL;
gchar *message = NULL; gchar *message = NULL;
@ -833,7 +833,7 @@ gnc_sx_sxsincelast_book_opened (void)
g_object_unref (G_OBJECT(inst_model)); g_object_unref (G_OBJECT(inst_model));
if (creation_errors) if (creation_errors)
creation_error_dialog (&creation_errors); gnc_ui_sx_creation_error_dialog (&creation_errors);
} }
static void static void
@ -1128,7 +1128,7 @@ dialog_response_cb (GtkDialog *dialog, gint response_id, GncSxSinceLastRunDialog
gnc_resume_gui_refresh (); gnc_resume_gui_refresh ();
gnc_gui_refresh_all (); // force a refresh of all registers gnc_gui_refresh_all (); // force a refresh of all registers
if (creation_errors) if (creation_errors)
creation_error_dialog (&creation_errors); gnc_ui_sx_creation_error_dialog (&creation_errors);
if (gtk_toggle_button_get_active (app_dialog->review_created_txns_toggle) if (gtk_toggle_button_get_active (app_dialog->review_created_txns_toggle)
&& g_list_length (app_dialog->created_txns) > 0) && g_list_length (app_dialog->created_txns) > 0)

View File

@ -52,4 +52,6 @@ GncSxSinceLastRunDialog* gnc_ui_sx_since_last_run_dialog (GtkWindow *parent,
GncSxInstanceModel *sx_instances, GncSxInstanceModel *sx_instances,
GList *auto_created_txn_guids); GList *auto_created_txn_guids);
void gnc_ui_sx_creation_error_dialog (GList **creation_errors);
#endif #endif

View File

@ -475,6 +475,7 @@ gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple,
GncSxInstanceModel *sx_instances; GncSxInstanceModel *sx_instances;
GncSxSummary summary; GncSxSummary summary;
GList *auto_created_txns = NULL; GList *auto_created_txns = NULL;
GList *creation_errors = NULL;
const char *nothing_to_do_msg = const char *nothing_to_do_msg =
_( "There are no Scheduled Transactions to be entered at this time." ); _( "There are no Scheduled Transactions to be entered at this time." );
@ -490,7 +491,8 @@ gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple,
sx_instances = gnc_sx_get_current_instances(); sx_instances = gnc_sx_get_current_instances();
gnc_sx_instance_model_summarize(sx_instances, &summary); gnc_sx_instance_model_summarize(sx_instances, &summary);
gnc_sx_instance_model_effect_change(sx_instances, TRUE, &auto_created_txns, NULL); gnc_sx_instance_model_effect_change(sx_instances, TRUE, &auto_created_txns,
&creation_errors);
if (auto_created_txns) if (auto_created_txns)
gnc_gui_refresh_all(); gnc_gui_refresh_all();
@ -521,6 +523,9 @@ gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple,
} }
g_list_free (auto_created_txns); g_list_free (auto_created_txns);
g_object_unref (G_OBJECT(sx_instances)); g_object_unref (G_OBJECT(sx_instances));
if (creation_errors)
gnc_ui_sx_creation_error_dialog (&creation_errors);
} }
static void static void

View File

@ -1478,9 +1478,12 @@ gnc_sx_instance_model_effect_change(GncSxInstanceModel *model,
gnc_sx_instance_model_change_instance_state gnc_sx_instance_model_change_instance_state
(model, inst, SX_INSTANCE_STATE_CREATED); (model, inst, SX_INSTANCE_STATE_CREATED);
} }
else else if (creation_errors)
{
*creation_errors = g_list_concat (*creation_errors, *creation_errors = g_list_concat (*creation_errors,
instance_errors); instance_errors);
instance_errors = NULL;
}
break; break;
case SX_INSTANCE_STATE_REMINDER: case SX_INSTANCE_STATE_REMINDER:
// do nothing // do nothing
@ -1490,6 +1493,9 @@ gnc_sx_instance_model_effect_change(GncSxInstanceModel *model,
g_assert_not_reached(); g_assert_not_reached();
break; break;
} }
if (instance_errors)
g_list_free_full (instance_errors, g_free);
} }
xaccSchedXactionSetLastOccurDate(instances->sx, last_occur_date); xaccSchedXactionSetLastOccurDate(instances->sx, last_occur_date);