mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[dialog-payment] plug some GLists leaks
and tidy up
This commit is contained in:
parent
5ebb544719
commit
cb5a9acf76
@ -1598,6 +1598,7 @@ static Split *select_payment_split (GtkWindow *parent, Transaction *txn)
|
|||||||
* The only exception would be a lot link transaction
|
* The only exception would be a lot link transaction
|
||||||
*/
|
*/
|
||||||
GList *payment_splits = xaccTransGetPaymentAcctSplitList (txn);
|
GList *payment_splits = xaccTransGetPaymentAcctSplitList (txn);
|
||||||
|
Split *selected_split = NULL;
|
||||||
if (!payment_splits)
|
if (!payment_splits)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
@ -1620,8 +1621,6 @@ static Split *select_payment_split (GtkWindow *parent, Transaction *txn)
|
|||||||
|
|
||||||
if (g_list_length(payment_splits) > 1)
|
if (g_list_length(payment_splits) > 1)
|
||||||
{
|
{
|
||||||
Split *selected_split = NULL;
|
|
||||||
GList *node;
|
|
||||||
GtkWidget *first_rb = NULL;
|
GtkWidget *first_rb = NULL;
|
||||||
int answer = GTK_BUTTONS_OK;
|
int answer = GTK_BUTTONS_OK;
|
||||||
const char *message = _("While this transaction has multiple splits that can be considered\n"
|
const char *message = _("While this transaction has multiple splits that can be considered\n"
|
||||||
@ -1639,7 +1638,7 @@ static Split *select_payment_split (GtkWindow *parent, Transaction *txn)
|
|||||||
gtk_box_pack_start (GTK_BOX(content), label, FALSE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX(content), label, FALSE, TRUE, 0);
|
||||||
|
|
||||||
/* Add splits as selectable options to the dialog */
|
/* Add splits as selectable options to the dialog */
|
||||||
for (node = payment_splits; node; node = node->next)
|
for (GList *node = payment_splits; node; node = node->next)
|
||||||
{
|
{
|
||||||
GtkWidget *rbutton;
|
GtkWidget *rbutton;
|
||||||
Split *split = node->data;
|
Split *split = node->data;
|
||||||
@ -1679,10 +1678,12 @@ static Split *select_payment_split (GtkWindow *parent, Transaction *txn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET(dialog));
|
gtk_widget_destroy (GTK_WIDGET(dialog));
|
||||||
return selected_split;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return payment_splits->data;
|
selected_split = payment_splits->data;
|
||||||
|
|
||||||
|
g_list_free (payment_splits);
|
||||||
|
return selected_split;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **post_acct, gboolean *abort)
|
static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **post_acct, gboolean *abort)
|
||||||
@ -1726,13 +1727,11 @@ static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **po
|
|||||||
else
|
else
|
||||||
apar_splits_no_lot = g_list_prepend (apar_splits_no_lot, post_split);
|
apar_splits_no_lot = g_list_prepend (apar_splits_no_lot, post_split);
|
||||||
}
|
}
|
||||||
g_list_free (apar_splits);
|
|
||||||
|
|
||||||
/* If no post_acct was selected from the postlots, fall back to the first apar split's
|
/* If no post_acct was selected from the postlots, fall back to the first apar split's
|
||||||
* account if there is one. */
|
* account if there is one. */
|
||||||
if (!*post_acct && apar_splits_no_lot)
|
if (!*post_acct && apar_splits_no_lot)
|
||||||
*post_acct = xaccSplitGetAccount (apar_splits_no_lot->data);
|
*post_acct = xaccSplitGetAccount (apar_splits_no_lot->data);
|
||||||
g_list_free (apar_splits_no_lot);
|
|
||||||
|
|
||||||
/* Abort if the txn has splits in more than one APAR account
|
/* Abort if the txn has splits in more than one APAR account
|
||||||
* GnuCash can only handle one post account per payment transaction.
|
* GnuCash can only handle one post account per payment transaction.
|
||||||
@ -1771,6 +1770,9 @@ static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **po
|
|||||||
txn_lots = NULL;
|
txn_lots = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_list_free (apar_splits);
|
||||||
|
g_list_free (apar_splits_no_lot);
|
||||||
|
g_list_free (unique_apar_accts);
|
||||||
return txn_lots;
|
return txn_lots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user