NullReferenceException in LayoutDocumentControl.OnModelChanged
Khaos66 opened this issue · 2 comments
Hi, when I use Drag&Drop to move a document and dock it in a new panel a NullReferenceException is thrown in OnModelChanged.
It seems that the line SetLayoutItem(Model.Root.Manager.GetLayoutItemFromModel(Model));
is the problem. The debugger shows that Model.Root is null. The CallStack is quite long:
AvalonDock.dll!AvalonDock.Controls.LayoutDocumentControl.OnModelChanged(System.Windows.DependencyPropertyChangedEventArgs e) Line 52 C#
AvalonDock.dll!AvalonDock.Controls.LayoutDocumentControl.OnModelChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Line 43 C#
[...]
AvalonDock.dll!AvalonDock.DockingManager.InternalRemoveLogicalChild(object element) Line 1441 C#
AvalonDock.dll!AvalonDock.Controls.LayoutFloatingWindowControl.FloatingWindowContentHost.DestroyWindowCore(System.Runtime.InteropServices.HandleRef hwnd) Line 137 C#
[...]
AvalonDock.dll!AvalonDock.Controls.LayoutFloatingWindowControl.OnClosed(System.EventArgs e) Line 536 C#
AvalonDock.dll!AvalonDock.Controls.LayoutDocumentFloatingWindowControl.OnClosed(System.EventArgs e) Line 150 C#
[...]
As you can see the method LayoutDocumentFloatingWindowControl.OnClosed
is called before the OnModelChanged
.
There the Root is disposed before the window is closed:
ILayoutRoot root = Model.Root;
if (root != null)
{
root.Manager.RemoveFloatingWindow(this);
root.CollectGarbage();
}
if (_overlayWindow != null)
{
_overlayWindow.Close();
_overlayWindow = null;
}
base.OnClosed(e);
[...]
Not sure why this is only a problem in my project. But looks logical to me, that a NullReferenceException is thrown.
@Dirkster99 I created a PR #241 for this issue. Please accept it and release a new version via Nuget. I'm stuck on this...
Thank you for releasing a new Nuget <3