That was exciting to track down. If your supplied sort.compareFunction(...) returns a value other
than -1, 0 or 1, Sort.findItem() goes into an infinite loop. Guard against that here. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@487 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -66,6 +66,7 @@ public class PlayerList extends VBox
|
|||||||
var sort :Sort = new Sort();
|
var sort :Sort = new Sort();
|
||||||
sort.compareFunction = sortFunction;
|
sort.compareFunction = sortFunction;
|
||||||
_players.sort = sort;
|
_players.sort = sort;
|
||||||
|
_players.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get scrollBarOnLeft () :Boolean
|
public function get scrollBarOnLeft () :Boolean
|
||||||
@@ -140,9 +141,10 @@ public class PlayerList extends VBox
|
|||||||
var data1 :Object = (o1 as Array)[1];
|
var data1 :Object = (o1 as Array)[1];
|
||||||
var data2 :Object = (o2 as Array)[1];
|
var data2 :Object = (o2 as Array)[1];
|
||||||
if (data1 is Comparable && data2 is Comparable) {
|
if (data1 is Comparable && data2 is Comparable) {
|
||||||
return (data1 as Comparable).compareTo(data2);
|
var compare :int = (data1 as Comparable).compareTo(data2);
|
||||||
|
return compare > 0 ? 1 : (compare < 0 ? -1 : 0);
|
||||||
} else {
|
} else {
|
||||||
// default to actionscript's magical great than or less than operators
|
// default to actionscript's magical greater than or less than operators
|
||||||
return data1 > data2 ? -1 : (data1 < data2 ? 1 : 0);
|
return data1 > data2 ? -1 : (data1 < data2 ? 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user