浏览代码

当在版本设置中连续按下mod右侧的“删除”按钮时,g概率导致PCL2崩溃。
Fixes #5402

hadesanc1 1 年之前
父节点
当前提交
3b1ab78fb9
共有 1 个文件被更改,包括 5 次插入 和 0 次删除
  1. 5 0
      Plain Craft Launcher 2/Modules/Minecraft/MyLocalModItem.xaml.vb

+ 5 - 0
Plain Craft Launcher 2/Modules/Minecraft/MyLocalModItem.xaml.vb

@@ -138,8 +138,13 @@ Public Class MyLocalModItem
         End If
         '计算滑动范围
         Dim Index = CType(Parent, StackPanel).Children.IndexOf(Me)
+        If Index < 0 OrElse Index >= CType(Parent, StackPanel).Children.Count Then Exit Sub
         SwipeStart = Math.Min(SwipeStart, Index)
         SwipeEnd = Math.Max(SwipeEnd, Index)
+        If SwipeStart < 0 Then SwipeStart = 0
+        If SwipeEnd < 0 Then SwipeEnd = 0
+        If SwipeStart >= CType(Parent, StackPanel).Children.Count Then SwipeStart = CType(Parent, StackPanel).Children.Count - 1
+        If SwipeEnd >= CType(Parent, StackPanel).Children.Count Then SwipeEnd = CType(Parent, StackPanel).Children.Count - 1
         '勾选所有范围中的项
         If SwipeStart = SwipeEnd Then Exit Sub
         For i = SwipeStart To SwipeEnd