Skip to content

Commit

Permalink
CsvTransExp - limit scope of variable to actual use
Browse files Browse the repository at this point in the history
  • Loading branch information
gjanssens committed Feb 14, 2023
1 parent aa0a68f commit 545f27c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion gnucash/import-export/csv-exp/assistant-csv-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ load_settings (CsvExportInfo *info)
info->separator_str = ",";
info->file_name = NULL;
info->starting_dir = NULL;
info->trans_list = NULL;

/* The default directory for the user to select files. */
info->starting_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
Expand Down
1 change: 0 additions & 1 deletion gnucash/import-export/csv-exp/assistant-csv-export.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ typedef struct
CsvExportType export_type;
CsvExportDate csvd;
CsvExportAcc csva;
GList *trans_list;

Query *query;
Account *account;
Expand Down
8 changes: 4 additions & 4 deletions gnucash/import-export/csv-exp/csv-transactions-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,14 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
}

/* Run the query */
GList *trans_list = NULL;
for (GList *splits = qof_query_run (info->query); splits; splits = splits->next)
{
Split *split = splits->data;

// Look for trans already exported in trans_list
Transaction *trans = xaccSplitGetParent (split);
if (g_list_find (info->trans_list, trans))
if (g_list_find (trans_list, trans))
continue;

// Look for blank split
Expand Down Expand Up @@ -498,11 +499,12 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
if (info->failed)
break;
}
info->trans_list = g_list_prepend (info->trans_list, trans); // add trans to trans_list
trans_list = g_list_prepend (trans_list, trans);
}

if (info->export_type == XML_EXPORT_TRANS)
qof_query_destroy (info->query);
g_list_free (trans_list);
}


Expand Down Expand Up @@ -590,8 +592,6 @@ void csv_transactions_export (CsvExportInfo *info)
else
account_splits (info, info->account, fh);

g_list_free (info->trans_list); // free trans_list

fclose (fh);
LEAVE("");
}
Expand Down

3 comments on commit 545f27c

@christopherlam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing bug 798806

@gjanssens
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can see why indeed. Please go ahead and revert.
Can you add a comment to explain why this is tracked globally ?

@christopherlam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok... The #1598 has rewritten the csv exporter fixing this too 🙂

Please sign in to comment.