gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Wed May 27 21:55:49 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/de9d6a33 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7218bfef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a584806e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ccdeda42 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0af5883d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1f8dfbac (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d65a29c4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ee4f0daa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2af5d52c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4f8652c2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/402b1c86 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c08215d0 (commit)
	from  https://github.com/Gnucash/gnucash/commit/fa769090 (commit)



commit de9d6a3339463af35e47036e9dfeaa7e8ad2aa2e
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 18:44:35 2020 -0700

    Delete Account: Use subaccount commodity for subaccount splits.
    
    It might be different from the parent account's. Also check the
    commodity, not the currency-or-parent; moving widgets to flidgets
    is just as bad as pounds to dollars.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index d9443b68a..de7008864 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1361,15 +1361,14 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
 }
 
 static int
-commodity_mismatch_dialog (const Account* account, GtkWindow* parent,
-                           gboolean is_account)
+commodity_mismatch_dialog (const Account* account, GtkWindow* parent)
 {
     int response;
     char *account_name = gnc_account_get_full_name (account);
     char* message = g_strdup_printf (
-        _("Account %s does not have the same currency as the %s you're "
-          "deleting.\nAre you sure you want to do this?"), account_name,
-        is_account ? "account" : "transactions");
+        _("Account %s does not have the same currency as the one you're "
+          "moving transactions from.\nAre you sure you want to do this?"),
+        account_name);
     GtkWidget* error_dialog =
         gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
                                 GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
@@ -1386,28 +1385,34 @@ commodity_mismatch_dialog (const Account* account, GtkWindow* parent,
 
 typedef struct
 {
-    Account *account;
+    Account *new_account;
+    Account *old_account;
     GNCAccountSel *selector;
     gboolean match;
     gboolean for_account;
 } Adopter;
 
 static void
-adopter_set_account_and_match (Adopter* adopter, gnc_commodity *commodity)
+adopter_set_account_and_match (Adopter* adopter)
 {
     if (!(adopter->selector &&
           gtk_widget_is_sensitive (GTK_WIDGET (adopter->selector))))
         return;
-    adopter->account = gnc_account_sel_get_account(adopter->selector);
-    adopter->match =
-        gnc_account_get_currency_or_parent (adopter->account) == commodity;
+    adopter->new_account = gnc_account_sel_get_account(adopter->selector);
+/* We care about the commodity only if we're moving transactions. */
+    if (!adopter->for_account && adopter->old_account && adopter->new_account)
+        adopter->match =
+            xaccAccountGetCommodity (adopter->new_account) ==
+            xaccAccountGetCommodity (adopter->old_account);
 }
 
 static void
-adopter_init (Adopter* adopter, GtkWidget *selector, gboolean for_account)
+adopter_init (Adopter* adopter, GtkWidget *selector, Account* account,
+              gboolean for_account)
 {
     adopter->selector = GNC_ACCOUNT_SEL (selector);
-    adopter->account = NULL;
+    adopter->new_account = NULL;
+    adopter->old_account = account;
     adopter->match = TRUE;
     adopter->for_account = for_account;
 }
@@ -1416,10 +1421,9 @@ static gboolean
 adopter_match (Adopter* adopter, GtkWindow *parent)
 {
     int result;
-    if (adopter->match)
+    if (adopter->match || adopter->for_account)
         return TRUE;
-    result = commodity_mismatch_dialog (adopter->account, parent,
-                                        adopter->for_account);
+    result = commodity_mismatch_dialog (adopter->new_account, parent);
     return (result == GTK_RESPONSE_ACCEPT);
 }
 
@@ -1431,6 +1435,17 @@ typedef struct
     delete_helper_t delete_res;
 } Adopters;
 
+static Account*
+account_subaccount (Account* account)
+{
+    Account* subaccount = NULL;
+    GList *subs = gnc_account_get_children (account);
+    if (g_list_length (subs) == 1)
+        subaccount = subs->data;
+    g_list_free (subs);
+    return subaccount;
+}
+
 static GtkWidget*
 account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt)
 {
@@ -1468,7 +1483,7 @@ account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt)
                   gppat_setup_account_selector (builder, dialog,
                                                 "trans_mas_hbox",
                                                 DELETE_DIALOG_TRANS_MAS),
-                  FALSE);
+                  account, FALSE);
 
     // Does the selected account have splits
     if (splits)
@@ -1495,14 +1510,15 @@ account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt)
     adopter_init (&adopt->subacct,
                   gppat_setup_account_selector (builder, dialog,
                                                 "sa_mas_hbox",
-                                                DELETE_DIALOG_SA_MAS), TRUE);
+                                                DELETE_DIALOG_SA_MAS),
+                  account, TRUE);
 
     // setup subaccount transaction selector
     adopter_init (&adopt->subtrans,
                   gppat_setup_account_selector (builder, dialog,
                                                 "sa_trans_mas_hbox",
                                                 DELETE_DIALOG_SA_TRANS_MAS),
-                  FALSE);
+                  account_subaccount (account), FALSE);
     g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS,
                       GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
 
@@ -1558,7 +1574,6 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     gint response;
     GList *filter = NULL;
     GtkWidget *dialog = NULL;
-    gnc_commodity *account_currency = NULL;
 
     if (account == NULL)
         return;
@@ -1590,6 +1605,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     }
 
     // If no transaction or children just delete it.
+    if (!(xaccAccountCountSplits (account, FALSE) &&
           gnc_account_n_children (account)))
     {
         do_delete_account (account, NULL, NULL, NULL);
@@ -1598,11 +1614,6 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
 
     dialog = account_delete_dialog (account, GTK_WINDOW (window), &adopt);
 
-    account_currency = gnc_account_get_currency_or_parent (account);
-    /* Ideally we should check all subaccount currencies, and verify they're all
-     * identical. If not, it's not advisable to move subaccount currencies to a
-     * new account.
-     */
     while (TRUE)
     {
         response = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -1616,9 +1627,9 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
             g_list_free(filter);
             return;
         }
-        adopter_set_account_and_match (&adopt.trans, account_currency);
-        adopter_set_account_and_match (&adopt.subacct, account_currency);
-        adopter_set_account_and_match (&adopt.subtrans, account_currency);
+        adopter_set_account_and_match (&adopt.trans);
+        adopter_set_account_and_match (&adopt.subacct);
+        adopter_set_account_and_match (&adopt.subtrans);
 
         if (adopter_match (&adopt.trans, GTK_WINDOW (window)) &&
             adopter_match (&adopt.subacct, GTK_WINDOW (window)) &&
@@ -1628,11 +1639,12 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER);
     gtk_widget_destroy(dialog);
     g_list_free(filter);
-    if (confirm_delete_account (action, page, adopt.trans.account,
-                                adopt.subtrans.account, adopt.subacct.account,
+    if (confirm_delete_account (action, page, adopt.trans.new_account,
+                                adopt.subtrans.new_account,
+                                adopt.subacct.new_account,
                                 adopt.delete_res) == GTK_RESPONSE_ACCEPT)
-        do_delete_account (account, adopt.subacct.account,
-                           adopt.subtrans.account, adopt.trans.account);
+        do_delete_account (account, adopt.subacct.new_account,
+                           adopt.subtrans.new_account, adopt.trans.new_account);
 }
 
 static int

commit 7218bfef372693249b8ded5206951950b1814ee5
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 18:44:16 2020 -0700

    Delete Account: Short circuit checks if no transactions or subaccounts.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 242550f73..d9443b68a 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1589,6 +1589,13 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         return;
     }
 
+    // If no transaction or children just delete it.
+          gnc_account_n_children (account)))
+    {
+        do_delete_account (account, NULL, NULL, NULL);
+        return;
+    }
+
     dialog = account_delete_dialog (account, GTK_WINDOW (window), &adopt);
 
     account_currency = gnc_account_get_currency_or_parent (account);

commit a584806e070df198a73f9fc48722ea8f6903bd1b
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 17:36:38 2020 -0700

    Delete account: Rename and reflow helper functions.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index f7e4dea85..242550f73 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -88,11 +88,6 @@ typedef struct _delete_helper
 } delete_helper_t;
 
 
-static void delete_account_next (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
-                                 Account* sta, Account* saa, delete_helper_t delete_res);
-static void  delete_account_final (Account* account, Account* saa, Account* sta, Account* ta);
-
-
 #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-acct-tree"
 #define STATE_SECTION "Account Hierarchy"
 
@@ -179,6 +174,15 @@ static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkActi
 /* Command callback for new Register Test */
 static void gnc_plugin_page_account_tree_cmd_open2_account (GtkAction *action, GncPluginPageAccountTree *page);
 static void gnc_plugin_page_account_tree_cmd_open2_subaccounts (GtkAction *action, GncPluginPageAccountTree *page);
+/* Account Deletion Actions. */
+static int confirm_delete_account (GtkAction *action,
+                                   GncPluginPageAccountTree *page, Account* ta,
+                                   Account* sta, Account* saa,
+                                   delete_helper_t delete_res);
+static void  do_delete_account (Account* account, Account* saa, Account* sta,
+                                Account* ta);
+
+
 
 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
 
@@ -1617,15 +1621,17 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER);
     gtk_widget_destroy(dialog);
     g_list_free(filter);
-    delete_account_next (action, page, adopt.trans.account,
-                         adopt.subtrans.account, adopt.subacct.account,
-                         adopt.delete_res);
+    if (confirm_delete_account (action, page, adopt.trans.account,
+                                adopt.subtrans.account, adopt.subacct.account,
+                                adopt.delete_res) == GTK_RESPONSE_ACCEPT)
+        do_delete_account (account, adopt.subacct.account,
+                           adopt.subtrans.account, adopt.trans.account);
 }
 
-static void
-delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
-                     Account* ta, Account* sta, Account* saa,
-                     delete_helper_t delete_res)
+static int
+confirm_delete_account (GtkAction *action, GncPluginPageAccountTree *page,
+                        Account* ta, Account* sta, Account* saa,
+                        delete_helper_t delete_res)
 {
     Account *account = gnc_plugin_page_account_tree_get_current_account (page);
     GList* splits = xaccAccountGetSplitList(account);
@@ -1705,11 +1711,10 @@ delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
     response = gtk_dialog_run(GTK_DIALOG(dialog));
     gtk_widget_destroy(dialog);
-    if (response == GTK_RESPONSE_ACCEPT)
-        delete_account_final (account, saa, sta, ta);
+    return response;
 }
 
-void delete_account_final (Account* account, Account* saa, Account* sta, Account* ta)
+void do_delete_account (Account* account, Account* saa, Account* sta, Account* ta)
 {
     GList *acct_list, *ptr;
     const GncGUID *guid;

commit ccdeda4292f247514b4fe48e620246694cba067d
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 17:13:18 2020 -0700

    Extract function account_delete_dialog.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 83119194a..f7e4dea85 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1419,65 +1419,36 @@ adopter_match (Adopter* adopter, GtkWindow *parent)
     return (result == GTK_RESPONSE_ACCEPT);
 }
 
-static void
-gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
+typedef struct
+{
+    Adopter trans;
+    Adopter subacct;
+    Adopter subtrans;
+    delete_helper_t delete_res;
+} Adopters;
+
+static GtkWidget*
+account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt)
 {
-    Account *account = gnc_plugin_page_account_tree_get_current_account (page);
-    gchar *acct_name;
-    delete_helper_t delete_res = { FALSE, FALSE };
-    GtkWidget *window;
-    Adopter trans_adopt;
-    Adopter subacct_adopt;
-    Adopter sub_trans_adopt;
-    GList *splits;
-    GList* list;
-    gint response;
-    GList *filter = NULL;
-    GtkBuilder *builder = NULL;
     GtkWidget *dialog = NULL;
     GtkWidget *widget = NULL;
     gchar *title = NULL;
-    gnc_commodity *account_currency = NULL;
-
-    if (account == NULL)
-        return;
-
-    /* If the account has objects referring to it, show the list - the account can't be deleted until these
-       references are dealt with. */
-    list = qof_instance_get_referring_object_list(QOF_INSTANCE(account));
-    if (list != NULL)
-    {
-#define EXPLANATION _("The list below shows objects which make use of the account which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another account")
-
-        gnc_ui_object_references_show(EXPLANATION, list);
-        g_list_free(list);
-        return;
-    }
+    GtkBuilder *builder = gtk_builder_new();
+    gchar *acct_name = gnc_account_get_full_name(account);
+    GList* splits = xaccAccountGetSplitList(account);
+    GList* filter = g_list_prepend(NULL, (gpointer)xaccAccountGetType(account));
 
-    window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
-    acct_name = gnc_account_get_full_name(account);
     if (!acct_name)
         acct_name = g_strdup (_("(no name)"));
 
-    splits = xaccAccountGetSplitList(account);
-
-    if ((splits == NULL) && (gnc_account_n_children(account) == 0))
-        return;
-
-    if (gnc_account_n_children(account) > 1) {
-        gchar* message = g_strdup_printf("Account '%s' has more than one subaccount, move subaccounts or delete them before attempting to delete this account.", acct_name);
-        gnc_error_dialog(GTK_WINDOW(window),"%s", message);
-        g_free (message);
-        g_free(acct_name);
-        return;
-    }
-
-    builder = gtk_builder_new();
     gnc_builder_add_from_file (builder, "dialog-account.glade", "account_delete_dialog");
 
     dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_delete_dialog"));
-    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window));
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
 
+    /* FIXME: Same account type used for subaccount. */
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER, filter);
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT, account);
     widget = GTK_WIDGET(gtk_builder_get_object (builder, "header"));
     title = g_strdup_printf(_("Deleting account %s"), acct_name);
     gtk_label_set_text(GTK_LABEL(widget), title);
@@ -1487,17 +1458,9 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     widget = GTK_WIDGET(gtk_builder_get_object (builder, DELETE_DIALOG_OK_BUTTON));
     g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON, widget);
 
-    /*
-     * Reparent only to accounts of the same
-     * type as the one being deleted.
-     */
-    filter = g_list_prepend(NULL, (gpointer)xaccAccountGetType(account));
-    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER, filter);
-    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT, account);
-
     // Add the account selectors and enable sections as appropriate
     // setup transactions selector
-    adopter_init (&trans_adopt,
+    adopter_init (&adopt->trans,
                   gppat_setup_account_selector (builder, dialog,
                                                 "trans_mas_hbox",
                                                 DELETE_DIALOG_TRANS_MAS),
@@ -1525,13 +1488,13 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     }
 
     // setup subaccount account selector
-    adopter_init (&subacct_adopt,
+    adopter_init (&adopt->subacct,
                   gppat_setup_account_selector (builder, dialog,
                                                 "sa_mas_hbox",
                                                 DELETE_DIALOG_SA_MAS), TRUE);
 
     // setup subaccount transaction selector
-    adopter_init (&sub_trans_adopt,
+    adopter_init (&adopt->subtrans,
                   gppat_setup_account_selector (builder, dialog,
                                                 "sa_trans_mas_hbox",
                                                 DELETE_DIALOG_SA_TRANS_MAS),
@@ -1543,10 +1506,10 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     {
         // Check for RO txns in descendants
         gnc_account_foreach_descendant_until(account, delete_account_helper,
-                                             &delete_res);
-        if (delete_res.has_splits)
+                                             &adopt->delete_res);
+        if (adopt->delete_res.has_splits)
         {
-            if (delete_res.has_ro_splits)
+            if (adopt->delete_res.has_ro_splits)
             {
                 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_rw")));
                 widget = GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_drb"));
@@ -1577,10 +1540,53 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     gtk_builder_connect_signals(builder, dialog);
     g_object_unref(G_OBJECT(builder));
 
-    /*
-     * Note that one effect of the modal dialog is preventing
-     * the account selectors from being repopulated.
-     */
+    return dialog;
+}
+
+static void
+gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
+{
+    Account *account = gnc_plugin_page_account_tree_get_current_account (page);
+    gchar *acct_name;
+    GtkWidget *window;
+    Adopters adopt;
+    GList* list;
+    gint response;
+    GList *filter = NULL;
+    GtkWidget *dialog = NULL;
+    gnc_commodity *account_currency = NULL;
+
+    if (account == NULL)
+        return;
+
+    memset (&adopt, 0, sizeof (adopt));
+    /* If the account has objects referring to it, show the list - the account can't be deleted until these
+       references are dealt with. */
+    list = qof_instance_get_referring_object_list(QOF_INSTANCE(account));
+    if (list != NULL)
+    {
+#define EXPLANATION _("The list below shows objects which make use of the account which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another account")
+
+        gnc_ui_object_references_show(EXPLANATION, list);
+        g_list_free(list);
+        return;
+    }
+
+    window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
+    acct_name = gnc_account_get_full_name(account);
+    if (!acct_name)
+        acct_name = g_strdup (_("(no name)"));
+
+    if (gnc_account_n_children(account) > 1) {
+        gchar* message = g_strdup_printf("Account '%s' has more than one subaccount, move subaccounts or delete them before attempting to delete this account.", acct_name);
+        gnc_error_dialog(GTK_WINDOW(window),"%s", message);
+        g_free (message);
+        g_free(acct_name);
+        return;
+    }
+
+    dialog = account_delete_dialog (account, GTK_WINDOW (window), &adopt);
+
     account_currency = gnc_account_get_currency_or_parent (account);
     /* Ideally we should check all subaccount currencies, and verify they're all
      * identical. If not, it's not advisable to move subaccount currencies to a
@@ -1593,24 +1599,27 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         if (response != GTK_RESPONSE_ACCEPT)
         {
             /* Account deletion is cancelled, so clean up and return. */
+            filter = g_object_get_data (G_OBJECT (dialog),
+                                        DELETE_DIALOG_FILTER);
             gtk_widget_destroy(dialog);
             g_list_free(filter);
             return;
         }
-        adopter_set_account_and_match (&trans_adopt, account_currency);
-        adopter_set_account_and_match (&subacct_adopt, account_currency);
-        adopter_set_account_and_match (&sub_trans_adopt, account_currency);
+        adopter_set_account_and_match (&adopt.trans, account_currency);
+        adopter_set_account_and_match (&adopt.subacct, account_currency);
+        adopter_set_account_and_match (&adopt.subtrans, account_currency);
 
-        if (adopter_match (&trans_adopt, GTK_WINDOW (window)) &&
-            adopter_match (&subacct_adopt, GTK_WINDOW (window)) &&
-            adopter_match (&sub_trans_adopt, GTK_WINDOW (window)))
+        if (adopter_match (&adopt.trans, GTK_WINDOW (window)) &&
+            adopter_match (&adopt.subacct, GTK_WINDOW (window)) &&
+            adopter_match (&adopt.subtrans, GTK_WINDOW (window)))
             break;
     }
+        filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER);
     gtk_widget_destroy(dialog);
     g_list_free(filter);
-    delete_account_next (action, page, trans_adopt.account,
-                         sub_trans_adopt.account, subacct_adopt.account,
-                         delete_res);
+    delete_account_next (action, page, adopt.trans.account,
+                         adopt.subtrans.account, adopt.subacct.account,
+                         adopt.delete_res);
 }
 
 static void

commit 0af5883d6e6016481fd0a7f4fbe8e4ad42785c4c
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 16:19:59 2020 -0700

    Delete Account: Abstract the disposition adopters into a struct.
    
    With functions for the operations done on the members.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 2ace27caf..83119194a 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1357,13 +1357,15 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
 }
 
 static int
-commodity_mismatch_dialog (const Account* account, GtkWindow* parent)
+commodity_mismatch_dialog (const Account* account, GtkWindow* parent,
+                           gboolean is_account)
 {
     int response;
     char *account_name = gnc_account_get_full_name (account);
     char* message = g_strdup_printf (
-        _("Account %s does not have the same currency as the account you're "
-          "deleting.\nAre you sure you want to do this?"), account_name);
+        _("Account %s does not have the same currency as the %s you're "
+          "deleting.\nAre you sure you want to do this?"), account_name,
+        is_account ? "account" : "transactions");
     GtkWidget* error_dialog =
         gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
                                 GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
@@ -1378,6 +1380,44 @@ commodity_mismatch_dialog (const Account* account, GtkWindow* parent)
     return response;
 }
 
+typedef struct
+{
+    Account *account;
+    GNCAccountSel *selector;
+    gboolean match;
+    gboolean for_account;
+} Adopter;
+
+static void
+adopter_set_account_and_match (Adopter* adopter, gnc_commodity *commodity)
+{
+    if (!(adopter->selector &&
+          gtk_widget_is_sensitive (GTK_WIDGET (adopter->selector))))
+        return;
+    adopter->account = gnc_account_sel_get_account(adopter->selector);
+    adopter->match =
+        gnc_account_get_currency_or_parent (adopter->account) == commodity;
+}
+
+static void
+adopter_init (Adopter* adopter, GtkWidget *selector, gboolean for_account)
+{
+    adopter->selector = GNC_ACCOUNT_SEL (selector);
+    adopter->account = NULL;
+    adopter->match = TRUE;
+    adopter->for_account = for_account;
+}
+
+static gboolean
+adopter_match (Adopter* adopter, GtkWindow *parent)
+{
+    int result;
+    if (adopter->match)
+        return TRUE;
+    result = commodity_mismatch_dialog (adopter->account, parent,
+                                        adopter->for_account);
+    return (result == GTK_RESPONSE_ACCEPT);
+}
 
 static void
 gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
@@ -1386,18 +1426,12 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     gchar *acct_name;
     delete_helper_t delete_res = { FALSE, FALSE };
     GtkWidget *window;
-    GtkWidget *trans_mas = NULL; /* transaction move to account selector */
-    GtkWidget *sa_mas = NULL;    /* subaccount move to account selector */
-    GtkWidget *sa_trans_mas = NULL; /* subaccount's transaction move to account selector */
-    Account *ta = NULL; /* transaction adopter */
-    Account *saa = NULL; /* subaccount adopter */
-    Account *sta = NULL; /* subaccount transaction adopter */
+    Adopter trans_adopt;
+    Adopter subacct_adopt;
+    Adopter sub_trans_adopt;
     GList *splits;
     GList* list;
     gint response;
-    gboolean ta_match = FALSE;
-    gboolean sta_match = FALSE;
-    gboolean saa_match = FALSE;
     GList *filter = NULL;
     GtkBuilder *builder = NULL;
     GtkWidget *dialog = NULL;
@@ -1463,7 +1497,11 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
 
     // Add the account selectors and enable sections as appropriate
     // setup transactions selector
-    trans_mas = gppat_setup_account_selector (builder, dialog, "trans_mas_hbox", DELETE_DIALOG_TRANS_MAS);
+    adopter_init (&trans_adopt,
+                  gppat_setup_account_selector (builder, dialog,
+                                                "trans_mas_hbox",
+                                                DELETE_DIALOG_TRANS_MAS),
+                  FALSE);
 
     // Does the selected account have splits
     if (splits)
@@ -1487,10 +1525,17 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     }
 
     // setup subaccount account selector
-    sa_mas = gppat_setup_account_selector (builder, dialog, "sa_mas_hbox", DELETE_DIALOG_SA_MAS);
+    adopter_init (&subacct_adopt,
+                  gppat_setup_account_selector (builder, dialog,
+                                                "sa_mas_hbox",
+                                                DELETE_DIALOG_SA_MAS), TRUE);
 
     // setup subaccount transaction selector
-    sa_trans_mas = gppat_setup_account_selector (builder, dialog, "sa_trans_mas_hbox", DELETE_DIALOG_SA_TRANS_MAS);
+    adopter_init (&sub_trans_adopt,
+                  gppat_setup_account_selector (builder, dialog,
+                                                "sa_trans_mas_hbox",
+                                                DELETE_DIALOG_SA_TRANS_MAS),
+                  FALSE);
     g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS,
                       GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
 
@@ -1541,12 +1586,10 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
      * identical. If not, it's not advisable to move subaccount currencies to a
      * new account.
      */
-    while (!ta_match || !sta_match || !saa_match)
+    while (TRUE)
     {
         response = gtk_dialog_run(GTK_DIALOG(dialog));
-        ta_match = TRUE;
-        sta_match = TRUE;
-        saa_match = TRUE;
+
         if (response != GTK_RESPONSE_ACCEPT)
         {
             /* Account deletion is cancelled, so clean up and return. */
@@ -1554,32 +1597,20 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
             g_list_free(filter);
             return;
         }
-        if (trans_mas && gtk_widget_is_sensitive(trans_mas))
-        {
-            ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
-            ta_match = gnc_account_get_currency_or_parent (ta) == account_currency;
-        }
-        if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
-        {
-            sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
-            sta_match = gnc_account_get_currency_or_parent (sta) == account_currency;
-        }
-        if (sa_mas && gtk_widget_is_sensitive(sa_mas))
-        {
-            saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
-            saa_match = gnc_account_get_currency_or_parent (saa) == account_currency;
-        }
-        if (!ta_match || !sta_match || !saa_match)
-        {
-            Account *acc = (!ta_match) ?  ta : (!sta_match) ?  sta : saa;
-            int result = commodity_mismatch_dialog (acc, GTK_WINDOW (window));
-            if (result == GTK_RESPONSE_ACCEPT)
-                break;
-        }
+        adopter_set_account_and_match (&trans_adopt, account_currency);
+        adopter_set_account_and_match (&subacct_adopt, account_currency);
+        adopter_set_account_and_match (&sub_trans_adopt, account_currency);
+
+        if (adopter_match (&trans_adopt, GTK_WINDOW (window)) &&
+            adopter_match (&subacct_adopt, GTK_WINDOW (window)) &&
+            adopter_match (&sub_trans_adopt, GTK_WINDOW (window)))
+            break;
     }
     gtk_widget_destroy(dialog);
     g_list_free(filter);
-    delete_account_next (action, page, ta, sta, saa, delete_res);
+    delete_account_next (action, page, trans_adopt.account,
+                         sub_trans_adopt.account, subacct_adopt.account,
+                         delete_res);
 }
 
 static void
@@ -1592,7 +1623,7 @@ delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
     GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
     gint response;
 
-    char *lines[5];
+    char *lines[6] = {0};
     char *message;
     int i = 0;
     GtkWidget *dialog;
@@ -1607,7 +1638,7 @@ delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
         if (ta)
         {
             char *name = gnc_account_get_full_name(ta);
-            lines[++i] = g_strdup_printf (_("All transactions in this account"
+            lines[++i] = g_strdup_printf (_("All transactions in this account "
                                             "will be moved to the account %s."),
                                           name);
             g_free (name);

commit 1f8dfbac99ebac986c621e64ff661a3b58606387
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 16:17:30 2020 -0700

    Delete Account: Modify strings for single subaccount.
    
    Because we bail out and make the user sort it out if there is more
    than one subaccount.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 4565171c2..2ace27caf 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1618,19 +1618,18 @@ delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
                                             "will be deleted."));
         }
     }
-    if (gnc_account_n_children(account) > 0)
+    if (gnc_account_n_children(account))
     {
         if (saa)
         {
             char *name = gnc_account_get_full_name(saa);
-            lines[++i] = g_strdup_printf (_("All of its sub-accounts will be "
+            lines[++i] = g_strdup_printf (_("Its sub-account will be "
                                             "moved to the account %s."), name);
             g_free (name);
         }
         else
         {
-            lines[++i] = g_strdup_printf (_("All of its subaccounts will be "
-                                            "deleted."));
+            lines[++i] = g_strdup_printf (_("Its subaccount will be eleted."));
             if (sta)
             {
                 char *name = gnc_account_get_full_name(sta);
diff --git a/gnucash/gtkbuilder/dialog-account.glade b/gnucash/gtkbuilder/dialog-account.glade
index 7f77ee363..e35091437 100644
--- a/gnucash/gtkbuilder/dialog-account.glade
+++ b/gnucash/gtkbuilder/dialog-account.glade
@@ -504,7 +504,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="halign">start</property>
-                        <property name="label" translatable="yes">This account contains sub-accounts. What would you like to do with these sub-accounts?</property>
+                        <property name="label" translatable="yes">This account has a sub-account. What would you like to do with it?</property>
                         <property name="wrap">True</property>
                       </object>
                       <packing>
@@ -533,7 +533,7 @@
                     </child>
                     <child>
                       <object class="GtkRadioButton" id="sa_drb">
-                        <property name="label" translatable="yes">Delete all _subaccounts</property>
+                        <property name="label" translatable="yes">Delete the _subaccount</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
@@ -761,7 +761,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="halign">start</property>
-                        <property name="label" translatable="yes">One or more sub-accounts contain transactions. What would you like to do with these transactions?</property>
+                        <property name="label" translatable="yes">You've said to delete the subaccount and it contains transactions. What would you like to do with these transactions?</property>
                         <property name="wrap">True</property>
                       </object>
                       <packing>

commit d65a29c4c0417d3f091323a8e6a86bf5fff2e151
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 12:02:56 2020 -0700

    gnc-plugin-page-account-tree.c: delete_account_next fix leaks and whitespace.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 0f2cbfe0b..4565171c2 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1583,67 +1583,76 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
 }
 
 static void
-delete_account_next (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
-                                                      Account* sta, Account* saa, delete_helper_t delete_res)
+delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
+                     Account* ta, Account* sta, Account* saa,
+                     delete_helper_t delete_res)
 {
     Account *account = gnc_plugin_page_account_tree_get_current_account (page);
     GList* splits = xaccAccountGetSplitList(account);
     GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
     gint response;
-    
-    const char *format = _("The account %s will be deleted.");
-    char *lines[8];
+
+    char *lines[5];
     char *message;
-    char *name;
     int i = 0;
     GtkWidget *dialog;
     gchar* acct_name = gnc_account_get_full_name(account);
-    
-    lines[0] = g_strdup_printf(format, acct_name);
+
+    lines[i] = g_strdup_printf (_("The account %s will be deleted."),
+                                acct_name);
     g_free(acct_name);
-    
+
     if (splits)
     {
         if (ta)
         {
-            lines[++i] = g_strdup_printf(_("All transactions in this account will be moved to "
-                                           "the account %s."), gnc_account_get_full_name(ta));
+            char *name = gnc_account_get_full_name(ta);
+            lines[++i] = g_strdup_printf (_("All transactions in this account"
+                                            "will be moved to the account %s."),
+                                          name);
+            g_free (name);
         }
         else
         {
-            lines[++i] = g_strdup_printf("%s", _("All transactions in this account will be deleted."));
+            lines[++i] = g_strdup_printf (_("All transactions in this account "
+                                            "will be deleted."));
         }
     }
     if (gnc_account_n_children(account) > 0)
     {
         if (saa)
         {
-            lines[++i] = g_strdup_printf(_("All of its sub-accounts will be moved to "
-                                           "the account %s."), gnc_account_get_full_name(saa));
+            char *name = gnc_account_get_full_name(saa);
+            lines[++i] = g_strdup_printf (_("All of its sub-accounts will be "
+                                            "moved to the account %s."), name);
+            g_free (name);
         }
         else
         {
-            lines[++i] = g_strdup_printf("%s", _("All of its subaccounts will be deleted."));
+            lines[++i] = g_strdup_printf (_("All of its subaccounts will be "
+                                            "deleted."));
             if (sta)
             {
-                lines[++i] = g_strdup_printf(_("All sub-account transactions will be moved to "
-                                               "the account %s."), gnc_account_get_full_name(sta));
+                char *name = gnc_account_get_full_name(sta);
+                lines[++i] = g_strdup_printf (_("All sub-account transactions "
+                                                "will be moved to the "
+                                                "account %s."), name);
+                g_free (name);
             }
             else if (delete_res.has_splits)
             {
-                lines[++i] = g_strdup_printf("%s", _("All sub-account transactions will be deleted."));
+                lines[++i] = g_strdup_printf(_("All sub-account transactions "
+                                               "will be deleted."));
             }
         }
     }
+
     lines[++i] = _("Are you sure you want to do this?");
-    lines[i] = NULL;
-    i--; /* Don't try to free the constant question. */
+
     message = g_strjoinv(" ", lines);
-    while (i--)
-    {
-        g_free(lines[i]);
-    }
-    
+    for (int j = 0; j < i; ++j) // Don't try to free the last one, it's const.
+        g_free (lines[j]);
+
     dialog =  gtk_message_dialog_new(GTK_WINDOW(window),
                                      GTK_DIALOG_DESTROY_WITH_PARENT,
                                      GTK_MESSAGE_QUESTION,

commit ee4f0daa470af7a934e517cdb6ef97d553a811e1
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 10:28:42 2020 -0700

    Plugin-page-account: Extract function commodity_mismatch_dialog.

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index d44898f96..0f2cbfe0b 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1356,6 +1356,29 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
     return selector;
 }
 
+static int
+commodity_mismatch_dialog (const Account* account, GtkWindow* parent)
+{
+    int response;
+    char *account_name = gnc_account_get_full_name (account);
+    char* message = g_strdup_printf (
+        _("Account %s does not have the same currency as the account you're "
+          "deleting.\nAre you sure you want to do this?"), account_name);
+    GtkWidget* error_dialog =
+        gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+                                GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
+                                "%s", message);
+    gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
+                            _("_Pick another account"), GTK_RESPONSE_CANCEL,
+                            _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
+                            (gchar *)NULL);
+    response = gtk_dialog_run (GTK_DIALOG (error_dialog));
+    gtk_widget_destroy (error_dialog);
+    g_free (message);
+    return response;
+}
+
+
 static void
 gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
 {
@@ -1514,8 +1537,10 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
      * the account selectors from being repopulated.
      */
     account_currency = gnc_account_get_currency_or_parent (account);
-    // Ideally we should check all subaccount currencies, and verify they're all identical. If not, it's not advisable
-    // to move subaccount currencies to a new account.
+    /* Ideally we should check all subaccount currencies, and verify they're all
+     * identical. If not, it's not advisable to move subaccount currencies to a
+     * new account.
+     */
     while (!ta_match || !sta_match || !saa_match)
     {
         response = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -1546,24 +1571,10 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         }
         if (!ta_match || !sta_match || !saa_match)
         {
-            GtkWidget *error_dialog;
-            char* message = NULL;
-            char* a_name = (!ta_match) ?  gnc_account_get_full_name (ta) : (!sta_match) ?  gnc_account_get_full_name (sta) :
-                                          gnc_account_get_full_name (saa);
-            message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), a_name);
-            error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
-                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                   GTK_MESSAGE_ERROR,
-                                                   GTK_BUTTONS_NONE,
-                                                   "%s", message);
-            gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
-                                    _("_Pick another account"), GTK_RESPONSE_CANCEL,
-                                    _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
-                                    (gchar *)NULL);
-            response = gtk_dialog_run (GTK_DIALOG (error_dialog));
-            gtk_widget_destroy (error_dialog);
-            g_free (message);
-            if (response == GTK_RESPONSE_ACCEPT) break;
+            Account *acc = (!ta_match) ?  ta : (!sta_match) ?  sta : saa;
+            int result = commodity_mismatch_dialog (acc, GTK_WINDOW (window));
+            if (result == GTK_RESPONSE_ACCEPT)
+                break;
         }
     }
     gtk_widget_destroy(dialog);

commit 2af5d52c4cabe86c083d39047852adb81f4df386
Merge: fa769090e 4f8652c2e
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 27 18:49:33 2020 -0700

    Merge Jean Laroche's '797220_delete_account_wrong_currency' into master.


commit 4f8652c2e54d7914a6d599a530f977fdb844c4ba
Author: jean <you at example.com>
Date:   Wed May 6 20:49:14 2020 -0700

    Refactor, breaking large function.
    - gnc_plugin_page_account_tree_cmd_delete_account() is still too long but would be messy to break
    - rename the _int function and break it further
    - remove passing of account name
    - simplify some of the code by reversing if(...) to if(!...)

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index ffb300976..6689013c1 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -74,6 +74,25 @@
 /* This static indicates the debugging module that this .o belongs to.  */
 static QofLogModule log_module = GNC_MOD_GUI;
 
+
+/********************************************************************
+ * delete_account_helper
+ * See if this account has any splits present.  Set the user data
+ * and return the same value to stop walking the account tree if
+ * appropriate.
+ ********************************************************************/
+typedef struct _delete_helper
+{
+    gboolean has_splits;
+    gboolean has_ro_splits;
+} delete_helper_t;
+
+
+static void delete_account_next (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
+                                 Account* sta, Account* saa, delete_helper_t delete_res);
+static void  delete_account_final (Account* account, Account* saa, Account* sta, Account* ta);
+
+
 #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-acct-tree"
 #define STATE_SECTION "Account Hierarchy"
 
@@ -1207,18 +1226,6 @@ gnc_plugin_page_account_tree_cmd_cascade_color_account (GtkAction *action, GncPl
     LEAVE(" ");
 }
 
-/********************************************************************
- * delete_account_helper
- * See if this account has any splits present.  Set the user data
- * and return the same value to stop walking the account tree if
- * appropriate.
- ********************************************************************/
-typedef struct _delete_helper
-{
-    gboolean has_splits;
-    gboolean has_ro_splits;
-} delete_helper_t;
-
 static gpointer
 delete_account_helper (Account * account, gpointer data)
 {
@@ -1348,67 +1355,271 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
     return selector;
 }
 
-// This is a helper function for gnc_plugin_page_account_tree_cmd_delete_account
 static void
-gnc_plugin_page_account_tree_cmd_delete_account_int (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
-                                                    Account* sta, Account* saa, gchar* acct_name, delete_helper_t delete_res)
+gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
+{
+    Account *account = gnc_plugin_page_account_tree_get_current_account (page);
+    gchar *acct_name;
+    delete_helper_t delete_res = { FALSE, FALSE };
+    GtkWidget *window;
+    GtkWidget *trans_mas = NULL; /* transaction move to account selector */
+    GtkWidget *sa_mas = NULL;    /* subaccount move to account selector */
+    GtkWidget *sa_trans_mas = NULL; /* subaccount's transaction move to account selector */
+    Account *ta = NULL; /* transaction adopter */
+    Account *saa = NULL; /* subaccount adopter */
+    Account *sta = NULL; /* subaccount transaction adopter */
+    GList *splits;
+    GList* list;
+    gint response;
+    gboolean ta_match = FALSE;
+    gboolean sta_match = FALSE;
+    gboolean saa_match = FALSE;
+    GList *filter = NULL;
+    GtkBuilder *builder = NULL;
+    GtkWidget *dialog = NULL;
+    GtkWidget *widget = NULL;
+    gchar *title = NULL;
+    gnc_commodity *account_currency = NULL;
+
+    if (account == NULL)
+        return;
+
+    /* If the account has objects referring to it, show the list - the account can't be deleted until these
+       references are dealt with. */
+    list = qof_instance_get_referring_object_list(QOF_INSTANCE(account));
+    if (list != NULL)
+    {
+#define EXPLANATION _("The list below shows objects which make use of the account which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another account")
+
+        gnc_ui_object_references_show(EXPLANATION, list);
+        g_list_free(list);
+        return;
+    }
+
+    window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
+    acct_name = gnc_account_get_full_name(account);
+    if (!acct_name)
+        acct_name = g_strdup (_("(no name)"));
+
+    splits = xaccAccountGetSplitList(account);
+
+    if ((splits == NULL) && (gnc_account_n_children(account) == 0))
+        return;
+
+    if (gnc_account_n_children(account) > 1) {
+        gchar* message = g_strdup_printf("Account '%s' has more than one subaccount, move subaccounts or delete them before attempting to delete this account.", acct_name);
+        gnc_error_dialog(GTK_WINDOW(window),"%s", message);
+        g_free (message);
+        g_free(acct_name);
+        return;
+    }
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-account.glade", "account_delete_dialog");
+
+    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_delete_dialog"));
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window));
+
+    widget = GTK_WIDGET(gtk_builder_get_object (builder, "header"));
+    title = g_strdup_printf(_("Deleting account %s"), acct_name);
+    gtk_label_set_text(GTK_LABEL(widget), title);
+    g_free(title);
+    g_free(acct_name);
+
+    widget = GTK_WIDGET(gtk_builder_get_object (builder, DELETE_DIALOG_OK_BUTTON));
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON, widget);
+
+    /*
+     * Reparent only to accounts of the same
+     * type as the one being deleted.
+     */
+    filter = g_list_prepend(NULL, (gpointer)xaccAccountGetType(account));
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER, filter);
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT, account);
+
+    // Add the account selectors and enable sections as appropriate
+    // setup transactions selector
+    trans_mas = gppat_setup_account_selector (builder, dialog, "trans_mas_hbox", DELETE_DIALOG_TRANS_MAS);
+
+    // Does the selected account have splits
+    if (splits)
+    {
+        delete_helper_t delete_res2 = { FALSE, FALSE };
+
+        delete_account_helper(account, &delete_res2);
+        if (delete_res2.has_ro_splits)
+        {
+            gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_rw")));
+            widget = GTK_WIDGET(gtk_builder_get_object (builder, "trans_drb"));
+            gtk_widget_set_sensitive(widget, FALSE);
+        }
+        else
+            gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_ro")));
+    }
+    else
+    {
+        gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder, "transactions")), FALSE);
+        gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_ro")));
+    }
+
+    // setup subaccount account selector
+    sa_mas = gppat_setup_account_selector (builder, dialog, "sa_mas_hbox", DELETE_DIALOG_SA_MAS);
+
+    // setup subaccount transaction selector
+    sa_trans_mas = gppat_setup_account_selector (builder, dialog, "sa_trans_mas_hbox", DELETE_DIALOG_SA_TRANS_MAS);
+    g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS,
+                      GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
+
+    if (gnc_account_n_children(account) > 0)
+    {
+        // Check for RO txns in descendants
+        gnc_account_foreach_descendant_until(account, delete_account_helper,
+                                             &delete_res);
+        if (delete_res.has_splits)
+        {
+            if (delete_res.has_ro_splits)
+            {
+                gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_rw")));
+                widget = GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_drb"));
+                gtk_widget_set_sensitive(widget, FALSE);
+            }
+            else
+                gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
+
+            g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(1));
+        }
+        else
+        {
+            g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(0));
+            gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")), FALSE);
+            gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
+        }
+    }
+    else
+    {
+        gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder, "subaccounts")), FALSE);
+        gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")), FALSE);
+        gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
+    }
+
+    /* default to cancel */
+    gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
+
+    gtk_builder_connect_signals(builder, dialog);
+    g_object_unref(G_OBJECT(builder));
+
+    /*
+     * Note that one effect of the modal dialog is preventing
+     * the account selectors from being repopulated.
+     */
+    account_currency = gnc_account_get_currency_or_parent (account);
+    // Ideally we should check all subaccount currencies, and verify they're all identical. If not, it's not advisable
+    // to move subaccount currencies to a new account.
+    while (!ta_match || !sta_match || !saa_match)
+    {
+        response = gtk_dialog_run(GTK_DIALOG(dialog));
+        ta_match = TRUE;
+        sta_match = TRUE;
+        saa_match = TRUE;
+        if (response != GTK_RESPONSE_ACCEPT)
+        {
+            /* Account deletion is cancelled, so clean up and return. */
+            gtk_widget_destroy(dialog);
+            g_list_free(filter);
+            return;
+        }
+        if (trans_mas && gtk_widget_is_sensitive(trans_mas))
+        {
+            ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
+            ta_match = gnc_account_get_currency_or_parent (ta) == account_currency;
+        }
+        if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
+        {
+            sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
+            sta_match = gnc_account_get_currency_or_parent (sta) == account_currency;
+        }
+        if (sa_mas && gtk_widget_is_sensitive(sa_mas))
+        {
+            saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
+            saa_match = gnc_account_get_currency_or_parent (saa) == account_currency;
+        }
+        if (!ta_match || !sta_match || !saa_match)
+        {
+            GtkWidget *error_dialog;
+            char* message = NULL;
+            char* a_name = (!ta_match) ?  gnc_account_get_full_name (ta) : (!sta_match) ?  gnc_account_get_full_name (sta) :
+                                          gnc_account_get_full_name (saa);
+            message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), a_name);
+            error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   GTK_MESSAGE_ERROR,
+                                                   GTK_BUTTONS_NONE,
+                                                   "%s", message);
+            gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
+                                    _("_Pick another account"), GTK_RESPONSE_CANCEL,
+                                    _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
+                                    (gchar *)NULL);
+            response = gtk_dialog_run (GTK_DIALOG (error_dialog));
+            gtk_widget_destroy (error_dialog);
+            g_free (message);
+            if (response == GTK_RESPONSE_ACCEPT) break;
+        }
+    }
+    gtk_widget_destroy(dialog);
+    g_list_free(filter);
+    delete_account_next (action, page, ta, sta, saa, delete_res);
+}
+
+static void
+delete_account_next (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
+                                                      Account* sta, Account* saa, delete_helper_t delete_res)
 {
     Account *account = gnc_plugin_page_account_tree_get_current_account (page);
     GList* splits = xaccAccountGetSplitList(account);
     GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
     gint response;
     
-    /*
-     * Present a message to the user which specifies what will be
-     * deleted and what will be reparented, then ask for verification.
-     */
     const char *format = _("The account %s will be deleted.");
     char *lines[8];
     char *message;
     char *name;
     int i = 0;
     GtkWidget *dialog;
+    gchar* acct_name = gnc_account_get_full_name(account);
     
     lines[0] = g_strdup_printf(format, acct_name);
+    g_free(acct_name);
+    
     if (splits)
     {
         if (ta)
         {
-            name = gnc_account_get_full_name(ta);
-            format = _("All transactions in this account will be moved to "
-                       "the account %s.");
-            lines[++i] = g_strdup_printf(format, name);
+            lines[++i] = g_strdup_printf(_("All transactions in this account will be moved to "
+                                           "the account %s."), gnc_account_get_full_name(ta));
         }
-        else if (splits)
+        else
         {
-            format = _("All transactions in this account will be deleted.");
-            lines[++i] = g_strdup_printf("%s", format);
+            lines[++i] = g_strdup_printf("%s", _("All transactions in this account will be deleted."));
         }
     }
     if (gnc_account_n_children(account) > 0)
     {
         if (saa)
         {
-            name = gnc_account_get_full_name(saa);
-            format = _("All of its sub-accounts will be moved to "
-                       "the account %s.");
-            lines[++i] = g_strdup_printf(format, name);
+            lines[++i] = g_strdup_printf(_("All of its sub-accounts will be moved to "
+                                           "the account %s."), gnc_account_get_full_name(saa));
         }
         else
         {
-            format = _("All of its subaccounts will be deleted.");
-            lines[++i] = g_strdup_printf("%s", format);
+            lines[++i] = g_strdup_printf("%s", _("All of its subaccounts will be deleted."));
             if (sta)
             {
-                name = gnc_account_get_full_name(sta);
-                format = _("All sub-account transactions will be moved to "
-                           "the account %s.");
-                lines[++i] = g_strdup_printf(format, name);
+                lines[++i] = g_strdup_printf(_("All sub-account transactions will be moved to "
+                                               "the account %s."), gnc_account_get_full_name(sta));
             }
             else if (delete_res.has_splits)
             {
-                format = _("All sub-account transactions will be deleted.");
-                lines[++i] = g_strdup_printf("%s", format);
+                lines[++i] = g_strdup_printf("%s", _("All sub-account transactions will be deleted."));
             }
         }
     }
@@ -1434,300 +1645,70 @@ gnc_plugin_page_account_tree_cmd_delete_account_int (GtkAction *action, GncPlugi
     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
     response = gtk_dialog_run(GTK_DIALOG(dialog));
     gtk_widget_destroy(dialog);
+    if (response == GTK_RESPONSE_ACCEPT)
+        delete_account_final (account, saa, sta, ta);
+}
+
+void delete_account_final (Account* account, Account* saa, Account* sta, Account* ta)
+{
+    GList *acct_list, *ptr;
+    const GncGUID *guid;
+    gchar guidstr[GUID_ENCODING_LENGTH+1];
     
-    if (GTK_RESPONSE_ACCEPT == response)
+    gnc_set_busy_cursor(NULL, TRUE);
+    gnc_suspend_gui_refresh ();
+    
+    /* Move subaccounts and transactions if this was requested */
+    xaccAccountBeginEdit (account);
+    if (saa)
     {
-        GList *acct_list, *ptr;
-        const GncGUID *guid;
-        gchar guidstr[GUID_ENCODING_LENGTH+1];
-        
-        gnc_set_busy_cursor(NULL, TRUE);
-        gnc_suspend_gui_refresh ();
-        
-        /* Move subaccounts and transactions if this was requested */
-        xaccAccountBeginEdit (account);
-        if (saa)
-        {
-            
-            xaccAccountBeginEdit (saa);
-            acct_list = gnc_account_get_children(account);
-            for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
-                gnc_account_append_child (saa, ptr->data);
-            g_list_free(acct_list);
-            xaccAccountCommitEdit (saa);
-        }
-        else if (sta)
-        {
-            /* Move the splits of its subaccounts, if any. */
-            gnc_account_foreach_descendant(account,
-                                           (AccountCb)xaccAccountMoveAllSplits,
-                                           sta);
-        }
-        if (ta)
-        {
-            /* Move the splits of the account to be deleted. */
-            xaccAccountMoveAllSplits (account, ta);
-        }
-        xaccAccountCommitEdit (account);
-        
-        /* Drop all references from the state file for
-         * any subaccount the account still has
-         */
+        xaccAccountBeginEdit (saa);
         acct_list = gnc_account_get_children(account);
         for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
-        {
-            guid = xaccAccountGetGUID (ptr->data);
-            guid_to_string_buff (guid, guidstr);
-            gnc_state_drop_sections_for (guidstr);
-        }
+            gnc_account_append_child (saa, ptr->data);
         g_list_free(acct_list);
-        
-        /* Drop all references from the state file for this account
-         */
-        guid = xaccAccountGetGUID (account);
-        guid_to_string_buff (guid, guidstr);
-        gnc_state_drop_sections_for (guidstr);
-        
-        /*
-         * Finally, delete the account, any subaccounts it may still
-         * have, and any splits it or its subaccounts may still have.
-         */
-        xaccAccountBeginEdit (account);
-        xaccAccountDestroy (account);
-        gnc_resume_gui_refresh ();
-        gnc_unset_busy_cursor(NULL);
+        xaccAccountCommitEdit (saa);
     }
-    g_free(acct_name);
-}
-
-static void
-gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
-{
-    Account *account = gnc_plugin_page_account_tree_get_current_account (page);
-    gchar *acct_name;
-    delete_helper_t delete_res = { FALSE, FALSE };
-    GtkWidget *window;
-    GtkWidget *trans_mas = NULL; /* transaction move to account selector */
-    GtkWidget *sa_mas = NULL;    /* subaccount move to account selector */
-    GtkWidget *sa_trans_mas = NULL; /* subaccount's transaction move to account selector */
-    Account *ta = NULL; /* transaction adopter */
-    Account *saa = NULL; /* subaccount adopter */
-    Account *sta = NULL; /* subaccount transaction adopter */
-    GList *splits;
-    GList* list;
-    gint response;
-    gboolean ta_match = FALSE;
-    gboolean sta_match = FALSE;
-    gboolean saa_match = FALSE;
-
-    if (NULL == account)
-        return;
-
-    /* If the account has objects referring to it, show the list - the account can't be deleted until these
-       references are dealt with. */
-    list = qof_instance_get_referring_object_list(QOF_INSTANCE(account));
-    if (list != NULL)
+    else if (sta)
     {
-#define EXPLANATION _("The list below shows objects which make use of the account which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another account")
-
-        gnc_ui_object_references_show(EXPLANATION, list);
-        g_list_free(list);
-        return;
+        /* Move the splits of its subaccounts, if any. */
+        gnc_account_foreach_descendant(account,
+                                       (AccountCb)xaccAccountMoveAllSplits,
+                                       sta);
     }
-
-    window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
-    acct_name = gnc_account_get_full_name(account);
-    if (!acct_name)
+    if (ta)
     {
-        acct_name = g_strdup (_("(no name)"));
+        /* Move the splits of the account to be deleted. */
+        xaccAccountMoveAllSplits (account, ta);
     }
-
-    splits = xaccAccountGetSplitList(account);
-
-    /*
-     * If the account has transactions or child accounts then present a
-     * dialog to allow the user to specify what should be done with them.
+    xaccAccountCommitEdit (account);
+    
+    /* Drop all references from the state file for
+     * any subaccount the account still has
      */
-    if ((NULL != splits) || (gnc_account_n_children(account) > 0))
+    acct_list = gnc_account_get_children(account);
+    for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
     {
-        GList *filter = NULL;
-        GtkBuilder *builder = NULL;
-        GtkWidget *dialog = NULL;
-        GtkWidget *widget = NULL;
-        gchar *title = NULL;
-        gnc_commodity *account_currency = NULL;
-
-        builder = gtk_builder_new();
-        gnc_builder_add_from_file (builder, "dialog-account.glade", "account_delete_dialog");
-
-        dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_delete_dialog"));
-        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window));
-
-        widget = GTK_WIDGET(gtk_builder_get_object (builder, "header"));
-        title = g_strdup_printf(_("Deleting account %s"), acct_name);
-        gtk_label_set_text(GTK_LABEL(widget), title);
-        g_free(title);
-
-        widget = GTK_WIDGET(gtk_builder_get_object (builder, DELETE_DIALOG_OK_BUTTON));
-        g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON, widget);
-
-        /*
-         * Reparent only to accounts of the same
-         * type as the one being deleted.
-         */
-        filter = g_list_prepend(NULL, (gpointer)xaccAccountGetType(account));
-        g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER, filter);
-        g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT, account);
-
-        // Add the account selectors and enable sections as appropriate
-        // setup transactions selector
-        trans_mas = gppat_setup_account_selector (builder, dialog, "trans_mas_hbox", DELETE_DIALOG_TRANS_MAS);
-
-        // Does the selected account have splits
-        if (splits)
-        {
-            delete_helper_t delete_res2 = { FALSE, FALSE };
-
-            delete_account_helper(account, &delete_res2);
-            if (delete_res2.has_ro_splits)
-            {
-                gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_rw")));
-                widget = GTK_WIDGET(gtk_builder_get_object (builder, "trans_drb"));
-                gtk_widget_set_sensitive(widget, FALSE);
-            }
-            else
-                gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_ro")));
-        }
-        else
-        {
-            gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder, "transactions")), FALSE);
-            gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "trans_ro")));
-        }
-
-        // setup subaccount account selector
-        sa_mas = gppat_setup_account_selector (builder, dialog, "sa_mas_hbox", DELETE_DIALOG_SA_MAS);
-
-        // setup subaccount transaction selector
-        sa_trans_mas = gppat_setup_account_selector (builder, dialog, "sa_trans_mas_hbox", DELETE_DIALOG_SA_TRANS_MAS);
-        g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS,
-                          GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
-
-        // Does the selected account have sub accounts
-        if (gnc_account_n_children(account) > 1) {
-            // We don't delete accounts with more than 1 subaccount.
-            gchar* message = g_strdup_printf("Account '%s' has more than one subaccount, move subaccounts or delete them before attempting to delete this account.", acct_name);
-            dialog =  gtk_message_dialog_new (GTK_WINDOW(window),
-                                              GTK_DIALOG_DESTROY_WITH_PARENT,
-                                              GTK_MESSAGE_ERROR,
-                                              GTK_BUTTONS_OK,
-                                              "%s", message);
-            gtk_dialog_run (GTK_DIALOG (dialog));
-            gtk_widget_destroy (dialog);
-            g_free (message);
-            g_list_free(filter);
-            g_free(acct_name);
-            return;
-        }
-        if (gnc_account_n_children(account) > 0)
-        {
-            // Check for RO txns in descendants
-            gnc_account_foreach_descendant_until(account, delete_account_helper,
-                                                 &delete_res);
-            if (delete_res.has_splits)
-            {
-                if (delete_res.has_ro_splits)
-                {
-                    gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_rw")));
-                    widget = GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_drb"));
-                    gtk_widget_set_sensitive(widget, FALSE);
-                }
-                else
-                    gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
-
-                g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(1));
-            }
-            else
-            {
-                g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(0));
-                gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")), FALSE);
-                gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
-            }
-        }
-        else
-        {
-            gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder, "subaccounts")), FALSE);
-            gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")), FALSE);
-            gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder, "sa_trans_ro")));
-        }
-
-        /* default to cancel */
-        gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
-
-        gtk_builder_connect_signals(builder, dialog);
-        g_object_unref(G_OBJECT(builder));
-
-        /*
-         * Note that one effect of the modal dialog is preventing
-         * the account selectors from being repopulated.
-         */
-        account_currency = gnc_account_get_currency_or_parent (account);
-        // Ideally we should check all subaccount currencies, and verify they're all identical. If not, it's not advisable
-        // to move subaccount currencies to a new account.
-        while (!ta_match || !sta_match || !saa_match)
-        {
-            response = gtk_dialog_run(GTK_DIALOG(dialog));
-            ta_match = TRUE;
-            sta_match = TRUE;
-            saa_match = TRUE;
-            if (response != GTK_RESPONSE_ACCEPT)
-            {
-                /* Account deletion is cancelled, so clean up and return. */
-                gtk_widget_destroy(dialog);
-                g_list_free(filter);
-                g_free(acct_name);
-                return;
-            }
-            if (trans_mas && gtk_widget_is_sensitive(trans_mas))
-            {
-                ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
-                ta_match = gnc_account_get_currency_or_parent (ta) == account_currency;
-            }
-            if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
-            {
-                sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
-                sta_match = gnc_account_get_currency_or_parent (sta) == account_currency;
-            }
-            if (sa_mas && gtk_widget_is_sensitive(sa_mas))
-            {
-                saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
-                saa_match = gnc_account_get_currency_or_parent (saa) == account_currency;
-            }
-            if (!ta_match || !sta_match || !saa_match)
-            {
-                GtkWidget *error_dialog;
-                char* message = NULL;
-                char* a_name = (!ta_match) ?  gnc_account_get_full_name (ta) : (!sta_match) ?  gnc_account_get_full_name (sta) :
-                                              gnc_account_get_full_name (saa);
-                message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), a_name);
-                error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
-                                                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                       GTK_MESSAGE_ERROR,
-                                                       GTK_BUTTONS_NONE,
-                                                       "%s", message);
-                gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
-                                        _("_Pick another account"), GTK_RESPONSE_CANCEL,
-                                        _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
-                                        (gchar *)NULL);
-                response = gtk_dialog_run (GTK_DIALOG (error_dialog));
-                gtk_widget_destroy (error_dialog);
-                g_free (message);
-                if (response == GTK_RESPONSE_ACCEPT) break;
-            }
-        }
-        gtk_widget_destroy(dialog);
-        g_list_free(filter);
-    } /* (NULL != splits) || (NULL != children) */
-    gnc_plugin_page_account_tree_cmd_delete_account_int (action, page, ta, sta, saa, acct_name, delete_res);
+        guid = xaccAccountGetGUID (ptr->data);
+        guid_to_string_buff (guid, guidstr);
+        gnc_state_drop_sections_for (guidstr);
+    }
+    g_list_free(acct_list);
+    
+    /* Drop all references from the state file for this account
+     */
+    guid = xaccAccountGetGUID (account);
+    guid_to_string_buff (guid, guidstr);
+    gnc_state_drop_sections_for (guidstr);
+    
+    /*
+     * Finally, delete the account, any subaccounts it may still
+     * have, and any splits it or its subaccounts may still have.
+     */
+    xaccAccountBeginEdit (account);
+    xaccAccountDestroy (account);
+    gnc_resume_gui_refresh ();
+    gnc_unset_busy_cursor(NULL);
 }
 
 static void

commit 402b1c86a23b163a5f75158031a014132b04f63f
Author: jean <you at example.com>
Date:   Mon Apr 27 22:06:07 2020 -0700

    Split long function into two sub-functions. Prevent deleting accounts with more than 1 subaccount. Verify currency match for sub-account when it is to be moved or its transactions are to be moved

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index 1f9c013d1..ffb300976 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1348,6 +1348,158 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
     return selector;
 }
 
+// This is a helper function for gnc_plugin_page_account_tree_cmd_delete_account
+static void
+gnc_plugin_page_account_tree_cmd_delete_account_int (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
+                                                    Account* sta, Account* saa, gchar* acct_name, delete_helper_t delete_res)
+{
+    Account *account = gnc_plugin_page_account_tree_get_current_account (page);
+    GList* splits = xaccAccountGetSplitList(account);
+    GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
+    gint response;
+    
+    /*
+     * Present a message to the user which specifies what will be
+     * deleted and what will be reparented, then ask for verification.
+     */
+    const char *format = _("The account %s will be deleted.");
+    char *lines[8];
+    char *message;
+    char *name;
+    int i = 0;
+    GtkWidget *dialog;
+    
+    lines[0] = g_strdup_printf(format, acct_name);
+    if (splits)
+    {
+        if (ta)
+        {
+            name = gnc_account_get_full_name(ta);
+            format = _("All transactions in this account will be moved to "
+                       "the account %s.");
+            lines[++i] = g_strdup_printf(format, name);
+        }
+        else if (splits)
+        {
+            format = _("All transactions in this account will be deleted.");
+            lines[++i] = g_strdup_printf("%s", format);
+        }
+    }
+    if (gnc_account_n_children(account) > 0)
+    {
+        if (saa)
+        {
+            name = gnc_account_get_full_name(saa);
+            format = _("All of its sub-accounts will be moved to "
+                       "the account %s.");
+            lines[++i] = g_strdup_printf(format, name);
+        }
+        else
+        {
+            format = _("All of its subaccounts will be deleted.");
+            lines[++i] = g_strdup_printf("%s", format);
+            if (sta)
+            {
+                name = gnc_account_get_full_name(sta);
+                format = _("All sub-account transactions will be moved to "
+                           "the account %s.");
+                lines[++i] = g_strdup_printf(format, name);
+            }
+            else if (delete_res.has_splits)
+            {
+                format = _("All sub-account transactions will be deleted.");
+                lines[++i] = g_strdup_printf("%s", format);
+            }
+        }
+    }
+    lines[++i] = _("Are you sure you want to do this?");
+    lines[i] = NULL;
+    i--; /* Don't try to free the constant question. */
+    message = g_strjoinv(" ", lines);
+    while (i--)
+    {
+        g_free(lines[i]);
+    }
+    
+    dialog =  gtk_message_dialog_new(GTK_WINDOW(window),
+                                     GTK_DIALOG_DESTROY_WITH_PARENT,
+                                     GTK_MESSAGE_QUESTION,
+                                     GTK_BUTTONS_NONE,
+                                     "%s", message);
+    g_free(message);
+    gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+                           _("_Cancel"), GTK_RESPONSE_CANCEL,
+                           _("_Delete"), GTK_RESPONSE_ACCEPT,
+                           (gchar *)NULL);
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
+    response = gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_destroy(dialog);
+    
+    if (GTK_RESPONSE_ACCEPT == response)
+    {
+        GList *acct_list, *ptr;
+        const GncGUID *guid;
+        gchar guidstr[GUID_ENCODING_LENGTH+1];
+        
+        gnc_set_busy_cursor(NULL, TRUE);
+        gnc_suspend_gui_refresh ();
+        
+        /* Move subaccounts and transactions if this was requested */
+        xaccAccountBeginEdit (account);
+        if (saa)
+        {
+            
+            xaccAccountBeginEdit (saa);
+            acct_list = gnc_account_get_children(account);
+            for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
+                gnc_account_append_child (saa, ptr->data);
+            g_list_free(acct_list);
+            xaccAccountCommitEdit (saa);
+        }
+        else if (sta)
+        {
+            /* Move the splits of its subaccounts, if any. */
+            gnc_account_foreach_descendant(account,
+                                           (AccountCb)xaccAccountMoveAllSplits,
+                                           sta);
+        }
+        if (ta)
+        {
+            /* Move the splits of the account to be deleted. */
+            xaccAccountMoveAllSplits (account, ta);
+        }
+        xaccAccountCommitEdit (account);
+        
+        /* Drop all references from the state file for
+         * any subaccount the account still has
+         */
+        acct_list = gnc_account_get_children(account);
+        for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
+        {
+            guid = xaccAccountGetGUID (ptr->data);
+            guid_to_string_buff (guid, guidstr);
+            gnc_state_drop_sections_for (guidstr);
+        }
+        g_list_free(acct_list);
+        
+        /* Drop all references from the state file for this account
+         */
+        guid = xaccAccountGetGUID (account);
+        guid_to_string_buff (guid, guidstr);
+        gnc_state_drop_sections_for (guidstr);
+        
+        /*
+         * Finally, delete the account, any subaccounts it may still
+         * have, and any splits it or its subaccounts may still have.
+         */
+        xaccAccountBeginEdit (account);
+        xaccAccountDestroy (account);
+        gnc_resume_gui_refresh ();
+        gnc_unset_busy_cursor(NULL);
+    }
+    g_free(acct_name);
+}
+
 static void
 gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page)
 {
@@ -1365,6 +1517,8 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     GList* list;
     gint response;
     gboolean ta_match = FALSE;
+    gboolean sta_match = FALSE;
+    gboolean saa_match = FALSE;
 
     if (NULL == account)
         return;
@@ -1459,6 +1613,21 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
                           GTK_WIDGET(gtk_builder_get_object (builder, "subaccount_trans")));
 
         // Does the selected account have sub accounts
+        if (gnc_account_n_children(account) > 1) {
+            // We don't delete accounts with more than 1 subaccount.
+            gchar* message = g_strdup_printf("Account '%s' has more than one subaccount, move subaccounts or delete them before attempting to delete this account.", acct_name);
+            dialog =  gtk_message_dialog_new (GTK_WINDOW(window),
+                                              GTK_DIALOG_DESTROY_WITH_PARENT,
+                                              GTK_MESSAGE_ERROR,
+                                              GTK_BUTTONS_OK,
+                                              "%s", message);
+            gtk_dialog_run (GTK_DIALOG (dialog));
+            gtk_widget_destroy (dialog);
+            g_free (message);
+            g_list_free(filter);
+            g_free(acct_name);
+            return;
+        }
         if (gnc_account_n_children(account) > 0)
         {
             // Check for RO txns in descendants
@@ -1504,10 +1673,12 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         account_currency = gnc_account_get_currency_or_parent (account);
         // Ideally we should check all subaccount currencies, and verify they're all identical. If not, it's not advisable
         // to move subaccount currencies to a new account.
-        while (!ta_match)
+        while (!ta_match || !sta_match || !saa_match)
         {
             response = gtk_dialog_run(GTK_DIALOG(dialog));
             ta_match = TRUE;
+            sta_match = TRUE;
+            saa_match = TRUE;
             if (response != GTK_RESPONSE_ACCEPT)
             {
                 /* Account deletion is cancelled, so clean up and return. */
@@ -1521,19 +1692,28 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
                 ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
                 ta_match = gnc_account_get_currency_or_parent (ta) == account_currency;
             }
-            if (sa_mas && gtk_widget_is_sensitive(sa_mas))
-                saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
             if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
+            {
                 sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
-            if (!ta_match)
+                sta_match = gnc_account_get_currency_or_parent (sta) == account_currency;
+            }
+            if (sa_mas && gtk_widget_is_sensitive(sa_mas))
+            {
+                saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
+                saa_match = gnc_account_get_currency_or_parent (saa) == account_currency;
+            }
+            if (!ta_match || !sta_match || !saa_match)
             {
-                // The currencies in the account that we're deleting and the account we're moving transactions to don't match.
-                char* message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), gnc_account_get_full_name (ta));
-                GtkWidget *error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
-                                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                                  GTK_MESSAGE_ERROR,
-                                                                  GTK_BUTTONS_NONE,
-                                                                  "%s", message);
+                GtkWidget *error_dialog;
+                char* message = NULL;
+                char* a_name = (!ta_match) ?  gnc_account_get_full_name (ta) : (!sta_match) ?  gnc_account_get_full_name (sta) :
+                                              gnc_account_get_full_name (saa);
+                message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), a_name);
+                error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
+                                                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                       GTK_MESSAGE_ERROR,
+                                                       GTK_BUTTONS_NONE,
+                                                       "%s", message);
                 gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
                                         _("_Pick another account"), GTK_RESPONSE_CANCEL,
                                         _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
@@ -1547,149 +1727,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         gtk_widget_destroy(dialog);
         g_list_free(filter);
     } /* (NULL != splits) || (NULL != children) */
-
-    /*
-     * Present a message to the user which specifies what will be
-     * deleted and what will be reparented, then ask for verification.
-     */
-    {
-        const char *format = _("The account %s will be deleted.");
-        char *lines[8];
-        char *message;
-        char *name;
-        int i = 0;
-        GtkWidget *dialog;
-
-        lines[0] = g_strdup_printf(format, acct_name);
-        if (splits)
-        {
-            if (ta)
-            {
-                name = gnc_account_get_full_name(ta);
-                format = _("All transactions in this account will be moved to "
-                           "the account %s.");
-                lines[++i] = g_strdup_printf(format, name);
-            }
-            else if (splits)
-            {
-                format = _("All transactions in this account will be deleted.");
-                lines[++i] = g_strdup_printf("%s", format);
-            }
-        }
-        if (gnc_account_n_children(account) > 0)
-        {
-            if (saa)
-            {
-                name = gnc_account_get_full_name(saa);
-                format = _("All of its sub-accounts will be moved to "
-                           "the account %s.");
-                lines[++i] = g_strdup_printf(format, name);
-            }
-            else
-            {
-                format = _("All of its subaccounts will be deleted.");
-                lines[++i] = g_strdup_printf("%s", format);
-                if (sta)
-                {
-                    name = gnc_account_get_full_name(sta);
-                    format = _("All sub-account transactions will be moved to "
-                               "the account %s.");
-                    lines[++i] = g_strdup_printf(format, name);
-                }
-                else if (delete_res.has_splits)
-                {
-                    format = _("All sub-account transactions will be deleted.");
-                    lines[++i] = g_strdup_printf("%s", format);
-                }
-            }
-        }
-        lines[++i] = _("Are you sure you want to do this?");
-        lines[i] = NULL;
-        i--; /* Don't try to free the constant question. */
-        message = g_strjoinv(" ", lines);
-        while (i--)
-        {
-            g_free(lines[i]);
-        }
-
-        dialog =  gtk_message_dialog_new(GTK_WINDOW(window),
-                                         GTK_DIALOG_DESTROY_WITH_PARENT,
-                                         GTK_MESSAGE_QUESTION,
-                                         GTK_BUTTONS_NONE,
-                                         "%s", message);
-        g_free(message);
-        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
-                               _("_Cancel"), GTK_RESPONSE_CANCEL,
-                               _("_Delete"), GTK_RESPONSE_ACCEPT,
-                               (gchar *)NULL);
-        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
-        response = gtk_dialog_run(GTK_DIALOG(dialog));
-        gtk_widget_destroy(dialog);
-
-        if (GTK_RESPONSE_ACCEPT == response)
-        {
-            GList *acct_list, *ptr;
-            const GncGUID *guid;
-            gchar guidstr[GUID_ENCODING_LENGTH+1];
-
-            gnc_set_busy_cursor(NULL, TRUE);
-            gnc_suspend_gui_refresh ();
-
-            /* Move subaccounts and transactions if this was requested */
-            xaccAccountBeginEdit (account);
-            if (NULL != saa)
-            {
-
-                xaccAccountBeginEdit (saa);
-                acct_list = gnc_account_get_children(account);
-                for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
-                    gnc_account_append_child (saa, ptr->data);
-                g_list_free(acct_list);
-                xaccAccountCommitEdit (saa);
-            }
-            else if (NULL != sta)
-            {
-                /* Move the splits of its subaccounts, if any. */
-                gnc_account_foreach_descendant(account,
-                                               (AccountCb)xaccAccountMoveAllSplits,
-                                               sta);
-            }
-            if (NULL != ta)
-            {
-                /* Move the splits of the account to be deleted. */
-                xaccAccountMoveAllSplits (account, ta);
-            }
-            xaccAccountCommitEdit (account);
-
-            /* Drop all references from the state file for
-             * any subaccount the account still has
-             */
-            acct_list = gnc_account_get_children(account);
-            for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
-            {
-                guid = xaccAccountGetGUID (ptr->data);
-                guid_to_string_buff (guid, guidstr);
-                gnc_state_drop_sections_for (guidstr);
-            }
-            g_list_free(acct_list);
-
-            /* Drop all references from the state file for this account
-             */
-            guid = xaccAccountGetGUID (account);
-            guid_to_string_buff (guid, guidstr);
-            gnc_state_drop_sections_for (guidstr);
-
-            /*
-             * Finally, delete the account, any subaccounts it may still
-             * have, and any splits it or its subaccounts may still have.
-             */
-            xaccAccountBeginEdit (account);
-            xaccAccountDestroy (account);
-            gnc_resume_gui_refresh ();
-            gnc_unset_busy_cursor(NULL);
-        }
-    }
-    g_free(acct_name);
+    gnc_plugin_page_account_tree_cmd_delete_account_int (action, page, ta, sta, saa, acct_name, delete_res);
 }
 
 static void

commit c08215d01b558de70699b5289d61faafd2872442
Author: jean <you at example.com>
Date:   Sun Apr 26 23:24:50 2020 -0700

    Bug 797220 - delete account allows move of all transactions to account having non-matching currency

diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index c1d3396bd..1f9c013d1 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -1364,6 +1364,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
     GList *splits;
     GList* list;
     gint response;
+    gboolean ta_match = FALSE;
 
     if (NULL == account)
         return;
@@ -1400,6 +1401,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
         GtkWidget *dialog = NULL;
         GtkWidget *widget = NULL;
         gchar *title = NULL;
+        gnc_commodity *account_currency = NULL;
 
         builder = gtk_builder_new();
         gnc_builder_add_from_file (builder, "dialog-account.glade", "account_delete_dialog");
@@ -1499,21 +1501,49 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
          * Note that one effect of the modal dialog is preventing
          * the account selectors from being repopulated.
          */
-        response = gtk_dialog_run(GTK_DIALOG(dialog));
-        if (GTK_RESPONSE_ACCEPT != response)
+        account_currency = gnc_account_get_currency_or_parent (account);
+        // Ideally we should check all subaccount currencies, and verify they're all identical. If not, it's not advisable
+        // to move subaccount currencies to a new account.
+        while (!ta_match)
         {
-            /* Account deletion is cancelled, so clean up and return. */
-            gtk_widget_destroy(dialog);
-            g_list_free(filter);
-            g_free(acct_name);
-            return;
+            response = gtk_dialog_run(GTK_DIALOG(dialog));
+            ta_match = TRUE;
+            if (response != GTK_RESPONSE_ACCEPT)
+            {
+                /* Account deletion is cancelled, so clean up and return. */
+                gtk_widget_destroy(dialog);
+                g_list_free(filter);
+                g_free(acct_name);
+                return;
+            }
+            if (trans_mas && gtk_widget_is_sensitive(trans_mas))
+            {
+                ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
+                ta_match = gnc_account_get_currency_or_parent (ta) == account_currency;
+            }
+            if (sa_mas && gtk_widget_is_sensitive(sa_mas))
+                saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
+            if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
+                sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
+            if (!ta_match)
+            {
+                // The currencies in the account that we're deleting and the account we're moving transactions to don't match.
+                char* message = g_strdup_printf (_("Account %s does not have the same currency as the account you're deleting.\nAre you sure you want to do this?"), gnc_account_get_full_name (ta));
+                GtkWidget *error_dialog = gtk_message_dialog_new (GTK_WINDOW(window),
+                                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                                  GTK_MESSAGE_ERROR,
+                                                                  GTK_BUTTONS_NONE,
+                                                                  "%s", message);
+                gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
+                                        _("_Pick another account"), GTK_RESPONSE_CANCEL,
+                                        _("_Do it anyway"), GTK_RESPONSE_ACCEPT,
+                                        (gchar *)NULL);
+                response = gtk_dialog_run (GTK_DIALOG (error_dialog));
+                gtk_widget_destroy (error_dialog);
+                g_free (message);
+                if (response == GTK_RESPONSE_ACCEPT) break;
+            }
         }
-        if (trans_mas && gtk_widget_is_sensitive(trans_mas))
-            ta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(trans_mas));
-        if (sa_mas && gtk_widget_is_sensitive(sa_mas))
-            saa = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_mas));
-        if (sa_trans_mas && gtk_widget_is_sensitive(sa_trans_mas))
-            sta = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(sa_trans_mas));
         gtk_widget_destroy(dialog);
         g_list_free(filter);
     } /* (NULL != splits) || (NULL != children) */



Summary of changes:
 gnucash/gnome/gnc-plugin-page-account-tree.c | 670 ++++++++++++++++-----------
 gnucash/gtkbuilder/dialog-account.glade      |   6 +-
 2 files changed, 404 insertions(+), 272 deletions(-)



More information about the gnucash-changes mailing list