浏览代码

Fixed group delete from context menu

flabbet 4 年之前
父节点
当前提交
142b401a35
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      PixiEditor/Models/Layers/LayerStructure.cs

+ 6 - 2
PixiEditor/Models/Layers/LayerStructure.cs

@@ -639,8 +639,12 @@ namespace PixiEditor.Models.Layers
         {
         {
             foreach (var currentGroup in groups)
             foreach (var currentGroup in groups)
             {
             {
-                int topIndex = Owner.Layers.IndexOf(Owner.Layers.First(x => x.LayerGuid == currentGroup.EndLayerGuid));
-                int bottomIndex = Owner.Layers.IndexOf(Owner.Layers.First(x => x.LayerGuid == currentGroup.StartLayerGuid));
+                var endLayer = Owner.Layers.FirstOrDefault(x => x.LayerGuid == currentGroup.EndLayerGuid);
+                var startLayer = Owner.Layers.FirstOrDefault(x => x.LayerGuid == currentGroup.StartLayerGuid);
+                if (endLayer == null || startLayer == null) continue;
+
+                int topIndex = Owner.Layers.IndexOf(endLayer);
+                int bottomIndex = Owner.Layers.IndexOf(startLayer);
                 var layers = GetLayersInOrder(new GroupData(topIndex, bottomIndex));
                 var layers = GetLayersInOrder(new GroupData(topIndex, bottomIndex));
 
 
                 if (currentGroup.Subgroups.Count > 0)
                 if (currentGroup.Subgroups.Count > 0)