Skip to content

Commit 121846e

Browse files
committed
Fix rare crash in entity view sorting
1 parent ebef1ed commit 121846e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Torch.Server/ViewModels/Entities/EntityViewModel.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,20 @@ public virtual string GetSortedName(EntityTreeViewModel.SortEnum sort)
8585

8686
public virtual int CompareToSort(EntityViewModel other, EntityTreeViewModel.SortEnum sort)
8787
{
88+
if (other == null)
89+
return -1;
90+
8891
switch (sort)
8992
{
9093
case EntityTreeViewModel.SortEnum.Name:
94+
if (Name == null)
95+
{
96+
if (other.Name == null)
97+
return 0;
98+
return 1;
99+
}
100+
if (other.Name == null)
101+
return -1;
91102
return string.Compare(Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
92103
case EntityTreeViewModel.SortEnum.Size:
93104
return Entity.WorldVolume.Radius.CompareTo(other.Entity.WorldVolume.Radius);

0 commit comments

Comments
 (0)