From a005049c012e3250d16852bf8740c39a4ef7107d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Tue, 20 Jul 2021 19:22:09 +0200 Subject: [PATCH 1/2] Do not call First() --- src/Dock.Model/DockManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Dock.Model/DockManager.cs b/src/Dock.Model/DockManager.cs index e87ade479..c5e4f1e08 100644 --- a/src/Dock.Model/DockManager.cs +++ b/src/Dock.Model/DockManager.cs @@ -320,21 +320,24 @@ private bool DockDockIntoDock(IDock sourceDock, IDock targetDock, DragAction act if (visible.Count == 1) { - if (DockDockableIntoDock(visible.First(), targetDock, action, operation, bExecute) == false) + var sourceDockable = visible.FirstOrDefault(); + if (sourceDockable is { } && DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) { return false; } } else { - if (DockDockableIntoDock(visible.First(), targetDock, action, operation, bExecute) == false) + var sourceDockable = visible.FirstOrDefault(); + if (sourceDockable is { } && DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) { return false; } foreach (var dockable in visible.Skip(1)) { - if (DockDockableIntoDockable(dockable, visible.First(), action, bExecute) == false) + var targetDockable = visible.FirstOrDefault(); + if (targetDockable is { } && DockDockableIntoDockable(dockable, targetDockable, action, bExecute) == false) { return false; } From 75eb2ab5a305450b3c2a3d7156f8a5068e26d96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Tue, 20 Jul 2021 19:26:26 +0200 Subject: [PATCH 2/2] Update DockManager.cs --- src/Dock.Model/DockManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dock.Model/DockManager.cs b/src/Dock.Model/DockManager.cs index c5e4f1e08..3e0e9ec2e 100644 --- a/src/Dock.Model/DockManager.cs +++ b/src/Dock.Model/DockManager.cs @@ -321,7 +321,7 @@ private bool DockDockIntoDock(IDock sourceDock, IDock targetDock, DragAction act if (visible.Count == 1) { var sourceDockable = visible.FirstOrDefault(); - if (sourceDockable is { } && DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) + if (sourceDockable is null || DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) { return false; } @@ -329,7 +329,7 @@ private bool DockDockIntoDock(IDock sourceDock, IDock targetDock, DragAction act else { var sourceDockable = visible.FirstOrDefault(); - if (sourceDockable is { } && DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) + if (sourceDockable is null || DockDockableIntoDock(sourceDockable, targetDock, action, operation, bExecute) == false) { return false; } @@ -337,7 +337,7 @@ private bool DockDockIntoDock(IDock sourceDock, IDock targetDock, DragAction act foreach (var dockable in visible.Skip(1)) { var targetDockable = visible.FirstOrDefault(); - if (targetDockable is { } && DockDockableIntoDockable(dockable, targetDockable, action, bExecute) == false) + if (targetDockable is null || DockDockableIntoDockable(dockable, targetDockable, action, bExecute) == false) { return false; }