Fix rare crash in entity view sorting
This commit is contained in:
@@ -85,9 +85,20 @@ namespace Torch.Server.ViewModels.Entities
|
|||||||
|
|
||||||
public virtual int CompareToSort(EntityViewModel other, EntityTreeViewModel.SortEnum sort)
|
public virtual int CompareToSort(EntityViewModel other, EntityTreeViewModel.SortEnum sort)
|
||||||
{
|
{
|
||||||
|
if (other == null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
switch (sort)
|
switch (sort)
|
||||||
{
|
{
|
||||||
case EntityTreeViewModel.SortEnum.Name:
|
case EntityTreeViewModel.SortEnum.Name:
|
||||||
|
if (Name == null)
|
||||||
|
{
|
||||||
|
if (other.Name == null)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (other.Name == null)
|
||||||
|
return -1;
|
||||||
return string.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
|
return string.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
|
||||||
case EntityTreeViewModel.SortEnum.Size:
|
case EntityTreeViewModel.SortEnum.Size:
|
||||||
return Entity.WorldVolume.Radius.CompareTo(other.Entity.WorldVolume.Radius);
|
return Entity.WorldVolume.Radius.CompareTo(other.Entity.WorldVolume.Radius);
|
||||||
|
Reference in New Issue
Block a user