mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gnc-plugin-page-account-tree.c: delete_account_next fix leaks and whitespace.
This commit is contained in:
parent
ee4f0daa47
commit
d65a29c4c0
@ -1583,66 +1583,75 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_account_next (GtkAction *action, GncPluginPageAccountTree *page, Account* ta,
|
delete_account_next (GtkAction *action, GncPluginPageAccountTree *page,
|
||||||
Account* sta, Account* saa, delete_helper_t delete_res)
|
Account* ta, Account* sta, Account* saa,
|
||||||
|
delete_helper_t delete_res)
|
||||||
{
|
{
|
||||||
Account *account = gnc_plugin_page_account_tree_get_current_account (page);
|
Account *account = gnc_plugin_page_account_tree_get_current_account (page);
|
||||||
GList* splits = xaccAccountGetSplitList(account);
|
GList* splits = xaccAccountGetSplitList(account);
|
||||||
GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
|
GtkWidget* window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page));
|
||||||
gint response;
|
gint response;
|
||||||
|
|
||||||
const char *format = _("The account %s will be deleted.");
|
char *lines[5];
|
||||||
char *lines[8];
|
|
||||||
char *message;
|
char *message;
|
||||||
char *name;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
gchar* acct_name = gnc_account_get_full_name(account);
|
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);
|
g_free(acct_name);
|
||||||
|
|
||||||
if (splits)
|
if (splits)
|
||||||
{
|
{
|
||||||
if (ta)
|
if (ta)
|
||||||
{
|
{
|
||||||
lines[++i] = g_strdup_printf(_("All transactions in this account will be moved to "
|
char *name = gnc_account_get_full_name(ta);
|
||||||
"the account %s."), 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
|
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 (gnc_account_n_children(account) > 0)
|
||||||
{
|
{
|
||||||
if (saa)
|
if (saa)
|
||||||
{
|
{
|
||||||
lines[++i] = g_strdup_printf(_("All of its sub-accounts will be moved to "
|
char *name = gnc_account_get_full_name(saa);
|
||||||
"the account %s."), 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
|
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)
|
if (sta)
|
||||||
{
|
{
|
||||||
lines[++i] = g_strdup_printf(_("All sub-account transactions will be moved to "
|
char *name = gnc_account_get_full_name(sta);
|
||||||
"the account %s."), 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)
|
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] = _("Are you sure you want to do this?");
|
||||||
lines[i] = NULL;
|
|
||||||
i--; /* Don't try to free the constant question. */
|
|
||||||
message = g_strjoinv(" ", lines);
|
message = g_strjoinv(" ", lines);
|
||||||
while (i--)
|
for (int j = 0; j < i; ++j) // Don't try to free the last one, it's const.
|
||||||
{
|
g_free (lines[j]);
|
||||||
g_free(lines[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(window),
|
dialog = gtk_message_dialog_new(GTK_WINDOW(window),
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
Loading…
Reference in New Issue
Block a user