From c15aa6e1003ac68593a6b81853a2e1938d106dda Mon Sep 17 00:00:00 2001 From: Dirkster99 Date: Wed, 20 Nov 2019 19:06:40 +0100 Subject: [PATCH] HotFix on issue to void crash caused by threading issue https://github.com/Dirkster99/AvalonDock/issues/90 --- .../Controls/LayoutAnchorableTabItem.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs index 08c95a44..5aeb512b 100644 --- a/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs +++ b/source/Components/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs @@ -195,7 +195,13 @@ protected override void OnMouseEnter( MouseEventArgs e ) return; var childrenList = container.Children.ToList(); - containerPane.MoveChild( childrenList.IndexOf( _draggingItem.Model ), childrenList.IndexOf( model ) ); + + // Hotfix to avoid crash caused by a likely threading issue Back in the containerPane. + var oldIndex = childrenList.IndexOf( _draggingItem.Model ); + var newIndex = childrenList.IndexOf( model ); + + if (newIndex < containerPane.ChildrenCount && oldIndex > -1) + containerPane.MoveChild( oldIndex, newIndex ); } }