xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.85k stars 868 forks source link

NullReferenceException at OnMouseEnter in LayoutAnchorableTabItem #1354

Open Chocko opened 6 years ago

Chocko commented 6 years ago

Hello,

when using the Avalon Dock v3.4 (i.e. Git Commit c0d3a0a), there are sporadic NullReferenceExceptions in the OnMouseEnter method in the LayoutAnchorableTabItem (line 197). I guess its the "_draggingItem" which is null.

Line 197: containerPane.MoveChild( childrenList.IndexOf( _draggingItem.Model ), childrenList.IndexOf( model ) );

Details: System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Xceed.Wpf.AvalonDock StackTrace: at Xceed.Wpf.AvalonDock.Controls.LayoutAnchorableTabItem.OnMouseEnter(MouseEventArgs e) in (...)\wpftoolkit\ExtendedWPFToolkitSolution\Src\Xceed.Wpf.AvalonDock\Controls\LayoutAnchorableTabItem.cs:line 197

Chocko commented 6 years ago

Btw, in Commit 24ecc09 (v3.4) there was the check at the beginning of the method (_draggingItem != null) removed...

isbeorn commented 6 years ago

Hi there,

my application experiences the same issue after updating to avalondock 3.4.

Object reference not set to an instance of an object. at Xceed.Wpf.AvalonDock.Controls.LayoutAnchorableTabItem.OnMouseEnter(MouseEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action2 originChangedAction) at System.Windows.ReverseInheritProperty.OnOriginValueChanged(DependencyObject oldOrigin, DependencyObject newOrigin, IList1 otherOrigins, DeferredElementTreeState& oldTreeState, Action`2 originChangedAction) at System.Windows.Input.MouseDevice.ChangeMouseOver(IInputElement mouseOver, Int32 timestamp) at System.Windows.Input.MouseDevice.PreNotifyInput(Object sender, NotifyInputEventArgs e) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Chocko commented 6 years ago

Hi isbeorn,

thanks for your answer. Just in case you need a workaround: I have downloaded the repository and added the null-check at line 184 like this:

if( _draggingItem != null && 
    _draggingItem != this &&
    e.LeftButton == MouseButtonState.Pressed )

I guess this solves the issue...

Here is a patch file: issue#1354_workaround_patch.diff.txt

XceedBoucherS commented 6 years ago

Hi, This is already fixed in v3.5 and up with the check " _draggingItem != null". Thank you.

PavelG2010 commented 5 years ago

This is already fixed in v3.5 and up with the check " _draggingItem != null".

I downloaded the latest version 3.7 and watch the error "NullReferenceException in LayoutAnchorableTabItem"

XceedBoucherS commented 5 years ago

Hi, The v3.7 Plus version (free for 45 days) is only available on Xceed web site : https://xceed.com/xceed-toolkit-plus-for-wpf/ If this is the version you tested with the issue, can you explain in details your steps to reproduce the issue and give us the sample code you used. Thank you.

snooka2197 commented 5 years ago

This is already fixed in v3.5 and up with the check " _draggingItem != null".

Any ETA when v3.5 (non Plus version) is available?

JobaDiniz commented 5 years ago

This is already fixed in v3.5 and up with the check " _draggingItem != null".

Any ETA when v3.5 (non Plus version) is available?

I don't understand wpftoolkit patches releases... this fix should be out there, it's been 6 months :(

dgosbell commented 5 years ago

So is a new release due our soon? Or do I need to either rollback to 3.3 or fork the repo and fix this myself?

JobaDiniz commented 5 years ago

or fork the repo and fix this myself?

I did just that... the only thing that is needed is if (_draggingItem != null ...) and bug goes away

XceedBoucherS commented 5 years ago

Hi, v3.5 free version should be released in the next few days. Thank you.

dgosbell commented 5 years ago

Thanks for the update @XceedBoucherS this is great news :)