Avoid a global static variable by using g_list_sort_with_data.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16211 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-06-25 17:18:11 +00:00
parent e0cdcc67f5
commit fa28f0e4f0

View File

@ -319,11 +319,10 @@ static int cmp_func (QofQuerySort *sort, QofSortFunc default_sort,
return sort->obj_cmp (conva, convb);
}
static QofQuery * sortQuery = NULL;
static int sort_func (gconstpointer a, gconstpointer b)
static int sort_func (gconstpointer a, gconstpointer b, gpointer q)
{
int retval;
QofQuery *sortQuery = q;
g_return_val_if_fail (sortQuery, 0);
@ -735,16 +734,11 @@ static GList * qof_query_run_internal (QofQuery *q,
*/
matching_objects = g_list_reverse(matching_objects);
/* Now sort the matching objects based on the search criteria
* sortQuery is an unforgivable use of static global data...
* I just can't figure out how else to do this sanely.
*/
/* Now sort the matching objects based on the search criteria */
if (q->primary_sort.comp_fcn || q->primary_sort.obj_cmp ||
(q->primary_sort.use_default && q->defaultSort))
{
sortQuery = q;
matching_objects = g_list_sort(matching_objects, sort_func);
sortQuery = NULL;
matching_objects = g_list_sort_with_data(matching_objects, sort_func, q);
}
/* Crop the list to limit the number of splits. */