Summary: gtk client fails to sort files in load-save dialog
                 Project: Freeciv
            Submitted by: kernigh
            Submitted on: Sunday 07/25/2010 at 02:52
                Category: client-gtk-2.0
                Severity: 2 - Minor
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 2.2.1+ r17591
         Discussion Lock: Any
        Operating System: *BSD
         Planned Release: 



The list of files in the load dialog and save dialog of the gtk-2.0 client is
always a mess! The client never sorts the files, so I have difficulty finding
my file in the list. My newest save files are sometimes near the top,
sometimes near the bottom, so I need to search the entire list. The attached
_games-not-sorted.png_ shows part of this mess.

So I decided to add some code to my copy of 2.2.1+ (r17591) to sort the list.
I found that update_saves_store() in client/gui-gtk-2.0/pages.c grabs the list
from datafilelist_infix() in utility/shared.c, which is trying and failing to
qsort() the files. This is because compare_file_mtime_ptrs() never returns a
value less than zero. This gave me a partially sorted list, very different
from time order (_ls -t_) or name order (_ls_) or filesystem order (_ls

My OpenBSD _man qsort_ says, "The comparison function must return an integer
less than, equal to, or greater than zero if the first argument is considered
to be respectively less than, equal to, or greater than the second." So I
fixed compare_file_mtime_ptrs(A, B) to return -1 if A is newer than B. Now
the game sorts the list in _ls -t_ order, and I can find my recent saves at
the top of my list.

_p22-sort-saves.diff_ is my patch for S2_2. I know that 2.1.10 also has the
bug, but I made no patch for 2.1.10. I know nothing about Freeciv trunk.


File Attachments:

Date: Sunday 07/25/2010 at 02:52  Name: games-not-sorted.png  Size: 71kB  
By: kernigh
screenshot of the problem; patch that fixes S2_2
Date: Sunday 07/25/2010 at 02:52  Name: p22-sort-saves.diff  Size: 564B   By:
screenshot of the problem; patch that fixes S2_2


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to