<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39602 >
I got a crash. I selected many units with 'y', and then I typed on a
quickselect key '*' or '/':
#0 quickselect (ptile=0x101, qtype=SELECT_LAND) at
../utility/speclist.h:110
listsize = <value optimized out>
panytransporter = <value optimized out>
panymovesea = <value optimized out>
panysea = <value optimized out>
panymoveland = <value optimized out>
panyland = <value optimized out>
panymoveunit = <value optimized out>
panyunit = <value optimized out>
__PRETTY_FUNCTION__ = "quickselect"
#1 0x000000000041a79e in key_quickselect (qtype=SELECT_LAND) at
control.c:2704
punit2 = <value optimized out>
myiter = (struct genlist_link *) 0x1
#2 0x00000000004b86ae in keyboard_handler (w=0x9010a0, ev=0x1ee2b10,
data=<value optimized out>) at gui_main.c:587
No locals.
#3 0x00002afa41d1f68d in _gtk_marshal_BOOLEAN__BOXED ()
from /usr/lib/libgtk-x11-2.0.so.0
No symbol table info available.
#4 0x00002afa444187da in g_closure_invoke () from
/usr/lib/libgobject-2.0.so.0
No symbol table info available.
#5 0x00002afa44428408 in ?? () from /usr/lib/libgobject-2.0.so.0
No symbol table info available.
#6 0x00002afa44429617 in g_signal_emit_valist ()
from /usr/lib/libgobject-2.0.so.0
No symbol table info available.
#7 0x00002afa44429a13 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
No symbol table info available.
#8 0x00002afa41e1d13e in ?? () from /usr/lib/libgtk-x11-2.0.so.0
No symbol table info available.
#9 0x00002afa41d18d45 in gtk_propagate_event ()
from /usr/lib/libgtk-x11-2.0.so.0
No symbol table info available.
#10 0x00002afa41d19c91 in gtk_main_do_event ()
from /usr/lib/libgtk-x11-2.0.so.0
No symbol table info available.
#11 0x00002afa421bf45c in ?? () from /usr/lib/libgdk-x11-2.0.so.0
No symbol table info available.
#12 0x00002afa44a85a14 in g_main_context_dispatch ()
from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#13 0x00002afa44a8885d in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#14 0x00002afa44a88b6a in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#15 0x00002afa41d1a023 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#16 0x00000000004ba44a in ui_main (argc=1, argv=0x7fff690ed898)
at gui_main.c:1424
home = <value optimized out>
sig = <value optimized out>
style = <value optimized out>
#17 0x0000000000413f35 in main (argc=<value optimized out>,
argv=0x7fff690ed898) at civclient.c:357
i = 1
loglevel = 2
ui_options = <value optimized out>
ui_separator = <value optimized out>
option = <value optimized out>
user_tileset = false
/**************************************************************************
...
**************************************************************************/
void key_quickselect(enum quickselect_type qtype)
{
unit_list_iterate(get_units_in_focus(), punit) {
struct unit *punit2 = quickselect(punit->tile, qtype);
set_unit_focus_and_select(punit2);
} unit_list_iterate_end;
}
This function is all wrong. If you set a unit in focus whereas you are
iterating the same list, there will be in this function some free links.
set_unit_focus_and_select() will call unit_list_unlink_all(), then the
links which are always in the key_quickselect() function will be wrong.
Anyway I don't think it's a good idea to allow quickselect with many
selected units. I propose 2 patches...
--- client/control.c.old 2007-08-21 23:59:24.000000000 +0200
+++ client/control.c 2007-08-21 23:59:31.000000000 +0200
@@ -2709,9 +2709,13 @@
**************************************************************************/
void key_quickselect(enum quickselect_type qtype)
{
- unit_list_iterate(get_units_in_focus(), punit) {
- struct unit *punit2 = quickselect(punit->tile, qtype);
+ struct unit_list *punits = get_units_in_focus();
+ struct unit *punit;
- set_unit_focus_and_select(punit2);
- } unit_list_iterate_end;
+ if (unit_list_size(punits) == 0) {
+ return;
+ }
+
+ punit = unit_list_get(punits, 0);
+ set_unit_focus_and_select(quickselect(punit->tile, qtype));
}
--- client/control.c.old 2007-08-21 23:59:24.000000000 +0200
+++ client/control.c 2007-08-22 00:04:00.000000000 +0200
@@ -2709,9 +2709,15 @@
**************************************************************************/
void key_quickselect(enum quickselect_type qtype)
{
- unit_list_iterate(get_units_in_focus(), punit) {
- struct unit *punit2 = quickselect(punit->tile, qtype);
+ struct unit_list *punits = get_units_in_focus();
+ struct unit *punit;
+ int size = unit_list_size(punits);
- set_unit_focus_and_select(punit2);
- } unit_list_iterate_end;
+ if (size == 1) {
+ punit = unit_list_get(punits, 0);
+ set_unit_focus_and_select(quickselect(punit->tile, qtype));
+ } else if (size > 1) {
+ append_output_window(_("You can use 'quick select' "
+ "when many units are selected."));
+ }
}
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev