[FancyZones Editor] Fix FZ Editor crash on opening custom layout for editing (#10911)

This commit is contained in:
Seraphima Zykova
2021-04-26 16:32:18 +03:00
committed by GitHub
parent b2f47b9073
commit e9a0b58796
4 changed files with 69 additions and 30 deletions

View File

@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using FancyZonesEditor.Models;
@@ -121,7 +120,7 @@ namespace FancyZonesEditor
if (zoneCount > rows * cols)
{
throw new ArgumentException("Invalid index found in model.CellChildMap");
return;
}
var indexCount = Enumerable.Repeat(0, zoneCount).ToList();
@@ -147,33 +146,18 @@ namespace FancyZonesEditor
{
if (indexCount[index] == 0)
{
throw new ArgumentException("Indices in model.CellChildMap are not contiguous");
return;
}
if (indexCount[index] != (indexRowHigh[index] - indexRowLow[index] + 1) * (indexColHigh[index] - indexColLow[index] + 1))
{
throw new ArgumentException("One or more indices in model.CellChildMap don't form a rectangle");
return;
}
}
if (model.RowPercents.Count != rows)
if (model.RowPercents.Count != model.Rows || model.ColumnPercents.Count != model.Columns || model.RowPercents.Exists((x) => (x < 1)) || model.ColumnPercents.Exists((x) => (x < 1)))
{
throw new ArgumentException("model.RowPercents has invalid size");
}
if (model.ColumnPercents.Count != cols)
{
throw new ArgumentException("model.ColumnPercents has invalid size");
}
if (model.RowPercents.Exists((x) => (x < 1)))
{
throw new ArgumentException("Invalid value in model.RowPercents");
}
if (model.ColumnPercents.Exists((x) => (x < 1)))
{
throw new ArgumentException("Invalid value in model.ColumnPercents");
return;
}
var rowPrefixSum = PrefixSum(model.RowPercents);
@@ -181,7 +165,7 @@ namespace FancyZonesEditor
if (rowPrefixSum[rows] != Multiplier || colPrefixSum[cols] != Multiplier)
{
throw new ArgumentException();
return;
}
_zones = new List<Zone>(zoneCount);