From c382a887b645b15f01bfccb57cf2cbdf2e9a8fc7 Mon Sep 17 00:00:00 2001 From: Boris Dachev Date: Mon, 24 Aug 2020 13:14:42 +0300 Subject: [PATCH] Added additional check in UpdateRowColDefinitions to prevent crash in certain conditions. --- .../Components/AvalonDock/Controls/LayoutGridControl.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/Components/AvalonDock/Controls/LayoutGridControl.cs b/source/Components/AvalonDock/Controls/LayoutGridControl.cs index d38d89fd..4ba385d2 100644 --- a/source/Components/AvalonDock/Controls/LayoutGridControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutGridControl.cs @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ AvalonDock Copyright (C) 2007-2013 Xceed Software Inc. @@ -209,7 +209,8 @@ private void UpdateRowColDefinitions() { var iColumn = 0; var iChild = 0; - for (var iChildModel = 0; iChildModel < _model.Children.Count; iChildModel++, iColumn++, iChild++) + // BD: 24.08.2020 added check for iChild against InternalChildren.Count + for (var iChildModel = 0; iChildModel < _model.Children.Count && iChild < InternalChildren.Count; iChildModel++, iColumn++, iChild++) { var childModel = _model.Children[iChildModel] as ILayoutPositionableElement; ColumnDefinitions.Add(new ColumnDefinition @@ -244,7 +245,8 @@ private void UpdateRowColDefinitions() { var iRow = 0; var iChild = 0; - for (var iChildModel = 0; iChildModel < _model.Children.Count; iChildModel++, iRow++, iChild++) + // BD: 24.08.2020 added check for iChild against InternalChildren.Count + for (var iChildModel = 0; iChildModel < _model.Children.Count && iChild < InternalChildren.Count; iChildModel++, iRow++, iChild++) { var childModel = _model.Children[iChildModel] as ILayoutPositionableElement; RowDefinitions.Add(new RowDefinition