URL:
  <http://gna.org/bugs/?16296>

                 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: 

    _______________________________________________________

Details:

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
-f_).

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
<http://gna.org/bugs/download.php?file_id=9558>
-------------------------------------------------------
Date: Sunday 07/25/2010 at 02:52  Name: p22-sort-saves.diff  Size: 564B   By:
kernigh
screenshot of the problem; patch that fixes S2_2
<http://gna.org/bugs/download.php?file_id=9559>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?16296>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to