Re: GtkTreeModelSort insert function does not respect default sort



Darin Adler <darin bentspoon com> writes:

> Here's my cut at a patch. OK to commit?

> +#define NO_SORT_FUNC ((GtkTreeIterCompareFunc) 0x1)

Good idea.

> +  if (tree_model_sort->sort_column_id !=
> GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
> +    {

Jeez.  How did I lose this 'if'.



> +      GtkTreeDataSortHeader *header;
> +      
> +      header = _gtk_tree_data_list_get_header (tree_model_sort->sort_list,
> +                           tree_model_sort->sort_column_id);
> +      
> +      if (!header)
> +    return 0;

Should this happen?  Returning 0 arbitrarily seems wrong?  I'd rather
see a g_return_if_fail here then just silently return 0.

> +      func = header->func;
> +      data = header->data;
> +    }
> +  else
> +    {
> +      func = tree_model_sort->default_sort_func;
> +      data = tree_model_sort->default_sort_data;
> +      
> +      if (func == NO_SORT_FUNC)
> +    return 0;

This line here concerns me.  If func is NO_SORT_FUNC, then the order it
needs to return is the order it is in the child model, not just 0.

-Jonathan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]