From: Jean-Philippe Bruyère Date: Wed, 22 Sep 2021 06:17:30 +0000 (+0000) Subject: add try/catch in Table layouting to prevent schowcase editor to exit X-Git-Tag: v0.9.7-beta~6 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=25abdf909b7ff86d82205f6f267c1abe8405cc30;p=jp%2Fcrow.git add try/catch in Table layouting to prevent schowcase editor to exit --- diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs index babd4d59..834a5820 100644 --- a/Crow/src/Widgets/Table.cs +++ b/Crow/src/Widgets/Table.cs @@ -215,30 +215,37 @@ namespace Crow return; if (e.LayoutType == LayoutingType.Width) { Widget g = sender as Widget; - int cIdx = HeaderRow.Children.IndexOf (g); - if (cIdx < Columns.Count && Columns[cIdx].Width.IsFit) - searchLargestChildInColumn (cIdx); childrenRWLock.EnterReadLock (); - for (int i = 1; i < Children.Count; i++) { - TableRow row = Children[i] as TableRow; - if (row.Children.Count <= cIdx) - continue; - setRowCellWidth (row.Children[cIdx], g.Slot.Width); + try { + int cIdx = HeaderRow.Children.IndexOf (g); + if (cIdx < Columns.Count && Columns[cIdx].Width.IsFit) + searchLargestChildInColumn (cIdx); + for (int i = 1; i < Children.Count; i++) { + TableRow row = Children[i] as TableRow; + if (row.Children.Count <= cIdx) + continue; + setRowCellWidth (row.Children[cIdx], g.Slot.Width); + } + } catch { + } finally { + childrenRWLock.ExitReadLock (); } - childrenRWLock.ExitReadLock (); - RegisterForRedraw (); } else if (e.LayoutType == LayoutingType.X) { Widget g = sender as Widget; - int cIdx = HeaderRow.Children.IndexOf (g); childrenRWLock.EnterReadLock (); - for (int i = 1; i < Children.Count; i++) { - TableRow row = Children[i] as TableRow; - if (row.Children.Count <= cIdx) - continue; - row.Children[cIdx].Slot.X = g.Slot.X; + try { + int cIdx = HeaderRow.Children.IndexOf (g); + for (int i = 1; i < Children.Count; i++) { + TableRow row = Children[i] as TableRow; + if (row.Children.Count <= cIdx) + continue; + row.Children[cIdx].Slot.X = g.Slot.X; + } + } catch { + } finally { + childrenRWLock.ExitReadLock (); } - childrenRWLock.ExitReadLock (); RegisterForRedraw (); } } @@ -270,7 +277,7 @@ namespace Crow int largestWidth = 0; for (int i = 1; i < Children.Count; i++) { TableRow row = Children[i] as TableRow; - if (!row.IsVisible || row.Children.Count <= i) + if (row == null || !row.IsVisible || row.Children.Count <= i) continue; int cw = row.Children [cIdx]. measureRawSize (LayoutingType.Width); if (cw > largestWidth) {