Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Null Exception During Mouse Input (Read 8668 times)
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Null Exception During Mouse Input
Aug 10th, 2009 at 8:24pm
Print Post  
Hi

Following is a snippet from an exception that is occurring from time to time during node resize or link creation / movement. We've yet to create full reproduction code, as we can't find a flawless trigger, but thought we'd raised it so you folks are aware of it.

Thanks


Paul


"Object reference not set to an instance of an object."
at MindFusion.Diagramming.Wpf.InteractionState.IsAllowed(Point point)
at MindFusion.Diagramming.Wpf.Behaviors.BehaviorBase.OnMouseUp(Point mousePosition, MouseButton mouseButton)
at MindFusion.Diagramming.Wpf.Diagram.x355258a28dc3da25(MouseButtonEventArgs xfbf34718e704c6bc, Point xb30c565aa19aece6)
at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnPreviewMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
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.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
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, Int32 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)
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #1 - Aug 11th, 2009 at 11:09am
Print Post  
Are you deleting items or calling CancelDrag in response to NodeModifying or LinkModifying?
  
Back to top
 
IP Logged
 
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Re: Null Exception During Mouse Input
Reply #2 - Aug 11th, 2009 at 12:45pm
Print Post  
We have code in NodeModifying but it does not call CancelDrag (does very little in fact) - we are calling CancelDrag on NodeCreating though.

Thanks


Paul

  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #3 - Aug 11th, 2009 at 3:02pm
Print Post  
Hi Paul,

Which version of the control are you using?

Stoyan
  
Back to top
 
IP Logged
 
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Re: Null Exception During Mouse Input
Reply #4 - Aug 11th, 2009 at 5:29pm
Print Post  
We are using the lastest released version (that we're aware of) : 2.2.0.25609
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #5 - Aug 11th, 2009 at 7:06pm
Print Post  
What kind of Diagram.Behavior are you using?
  
Back to top
 
IP Logged
 
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Re: Null Exception During Mouse Input
Reply #6 - Aug 12th, 2009 at 12:05pm
Print Post  
We are not setting any diagram behaviour explicitly - we just use the things like disallowing self loops etc.
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #7 - Aug 12th, 2009 at 3:25pm
Print Post  
Could you copy here your init code and event handlers, or email them to support@mindfusion.eu? The code at the top of the stack looks like this

Code
Select All
public bool IsAllowed(Point point)
{
	if (action == Action.Create)
		return currentItem.AllowCreate(point, this);

	if (action == Action.Modify)
		return currentItem.AllowModify(point, this);

	if (action == Action.Split)
		return false;

	return true;
}
 



so if that's urgent we can easily add a fix that checks if currentItem is null. However we can't see any logical way for currentItem to become null while the interaction is in progress and would like to get to the bottom of it Smiley

Stoyan
  
Back to top
 
IP Logged
 
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Re: Null Exception During Mouse Input
Reply #8 - Aug 20th, 2009 at 12:22am
Print Post  
Hi sorry for the usual delay in my replies.

Diagram creation XAML is;
<MF:Diagram x:Name="oHypothesisDiagram" ZoomFactor="100" Width="Auto" Height="Auto" MeasureUnit="WpfPoint" Bounds="0,0,640,480" NodesExpandable="False" Background="{DynamicResource FlowBGBrush}" HorizontalAlignment="Left" VerticalAlignment="Top" AllowSelfLoops="False">
<MF:Diagram.LinkPen>
<Pen Brush="#FFFF7A08" Thickness="2"/>
</MF:Diagram.LinkPen>
</MF:Diagram>


c#;

oDiagram.NodeCreating += new NodeValidationEventHandler(oDiagram_NodeCreating);

oDiagram.LinkCreated += new LinkEventHandler(oDiagram_LinkCreated);
oDiagram.TreeCollapsed += new NodeEventHandler(oDiagram_TreeCollapsed);
oDiagram.TreeExpanded += new NodeEventHandler(oDiagram_TreeExpanded);
oDiagram.NodeModified += new NodeEventHandler(oDiagram_NodeModified);
oDiagram.LinkDeleted += new LinkEventHandler(oDiagram_LinkDeleted);
oDiagram.Background = new SolidColorBrush(Colors.Transparent);
oDiagram.RecursiveExpand = true;
oDiagram.Clicked += new DiagramEventHandler(oDiagram_Clicked);
oDiagram.NodeDeleted += new NodeEventHandler(oDiagram_NodeDeleted);
oDiagram.NodeModifying += new NodeValidationEventHandler(oDiagram_NodeModifying);
oDiagram.DragEnter += new DragEventHandler(oDiagram_DragEnter);
oDiagram.Drop += new DragEventHandler(oDiagram_Drop);
oDiagram.NodeDeleting += new NodeValidationEventHandler(oDiagram_NodeDeleting);

//' Replace clipboard related keyboard command bindings to prevent crashes
oDiagram.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (sender, args) => { DiagramCopy(sender, args); }));
oDiagram.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, (sender, args) => { DiagramCut(sender, args); }));

  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #9 - Aug 21st, 2009 at 3:52pm
Print Post  
Hi,

Could you email us a sample diagram xml saved from your application and the NodeCreating and NodeModifying code you are using? Could you also check if diagram.Items.Remove is called from some handler related to user interaction?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
Anthony_Jones
YaBB Newbies
*
Offline



Posts: 2
Joined: Aug 25th, 2009
Re: Null Exception During Mouse Input
Reply #10 - Aug 25th, 2009 at 1:05pm
Print Post  
Hi,

Unfortunately we can't save the diagram xml as we don't have serialisation working properly yet.

Our NodeCreating event calls CancelDrag in order to prevent users from drawing empty nodes on the diagram:

Code
Select All
void oHypothesisDiagram_NodeCreating(object sender, NodeValidationEventArgs e)
{
    e.CancelDrag();
} 



I've just tried removing e.CancelDrag(); and without it, I no longer seem to be getting this error in places where I can normally replicate it. The problem is, it is then possible to draw nodes - is there another way to prevent the user doing this?

NodeModifying is not being used. Although we are using diagram.Items.Remove in a number of places, as far as I am aware none of them are called from user interaction.

Anthony (working on the same project)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Null Exception During Mouse Input
Reply #11 - Aug 26th, 2009 at 6:25am
Print Post  
Hi,

Ok, we were able to reproduce this now. You might set Behavior = DrawLinks if you want to allow only links to be created.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anthony_Jones
YaBB Newbies
*
Offline



Posts: 2
Joined: Aug 25th, 2009
Re: Null Exception During Mouse Input
Reply #12 - Aug 27th, 2009 at 10:07am
Print Post  
It looks as though setting Behaviour = DrawLinks and removing CancelDrag from NodeCreating has fixed our problem.

Thanks for your help!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint