TreeView Crash

Topics related to the Krypton Toolkit.

Moderators: Phil Wright, Chris Porter

TreeView Crash

Postby VILANOR » Fri Apr 13, 2012 5:34 pm

Hi

I found this problem on the KryptonTreeView, I'm not sure about how to reproduce the problem but it happens suddenly.
On method :
protected override void WndProc(ref Message m)

There is a switch: switch (m.Msg) with some cases, but there is no case when m.Msg it's equal to 8270, so the switch jumps to the case by default, which provokes a NullReferenceException on this line : base.WndProc(ref m);

Displaying the error message: "Object reference not set to an instance of an object."
Any idea about how to fix the issue ?
Maybe just a try catch on default case, or something special needs to be done when the message it's 8270?

Thanks.
KryptonTreeviewCrash.JPG
KryptonTreeviewCrash.JPG (118.05 KiB) Viewed 596 times
VILANOR
 
Posts: 4
Joined: Fri Apr 13, 2012 5:12 pm

Re: TreeView Crash

Postby Pau » Sun Apr 15, 2012 7:45 pm

I get a similar crash.

It occurs on closing the application. It only occurs in "release mode" (not in debugging, or from Visual Studio). It occurs always.

System.NullReferenceException: Object reference not set to an instance of an object..
en ComponentFactory.Krypton.Toolkit.PaletteRedirect.GetContentDraw(PaletteContentStyle style, PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritRedirect.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContent.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContent.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritOverride.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritNode.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.ViewDrawContent.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewLayoutDocker.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewComposite.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewDrawSplitCanvas.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewDrawButton.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.UpdateItemHeight()
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.OnNeedPaint(Object sender, NeedLayoutEventArgs e)
en ComponentFactory.Krypton.Toolkit.VisualControlBase.PerformNeedPaint(Boolean needLayout)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.OnTreeViewLostFocus(Object sender, EventArgs e)
en System.Windows.Forms.Control.OnLostFocus(EventArgs e)
en System.Windows.Forms.Control.WmKillFocus(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.TreeView.WndProc(Message& m)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.InternalTreeView.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



As you can see, it also occurs in WndProc (I don't know if that is relevant).

Any help is appreciated.
Pau
 
Posts: 10
Joined: Thu Dec 23, 2010 12:01 am

Re: TreeView Crash

Postby Pau » Sun Apr 15, 2012 7:46 pm

On more thing: I just replaced all TreeView in my application with KryptonTreeView.

Obviously, the bug did not occur before replacement.
Pau
 
Posts: 10
Joined: Thu Dec 23, 2010 12:01 am

Re: TreeView Crash

Postby VILANOR » Mon Apr 16, 2012 12:00 am

What I did was put a "try catch" just where the error appeared, in the case by default of the switch inside the method WndProc of KrptonTreeView class.
It did not crash again since I put the "try catch".

Also.. I had to do the same for KryptonListBox class in the same method.. I wonder if I will need to put a "try catch" for each control.
VILANOR
 
Posts: 4
Joined: Fri Apr 13, 2012 5:12 pm

Re: TreeView Crash

Postby Pau » Mon Apr 16, 2012 9:43 am

Hello again,

In my case, the problem was in my code.

I could reproduce the bug in a very simple project with this code:


Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
Me.KryptonTreeView1.Dispose()
End Sub


And the excepcion raise while closing the main form...

System.NullReferenceException: Object reference not set to an instance of an object..
en ComponentFactory.Krypton.Toolkit.PaletteRedirect.GetContentDraw(PaletteContentStyle style, PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritRedirect.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContent.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContent.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritOverride.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.PaletteContentInheritNode.GetContentDraw(PaletteState state)
en ComponentFactory.Krypton.Toolkit.ViewDrawContent.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewLayoutDocker.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewComposite.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewDrawSplitCanvas.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.ViewDrawButton.GetPreferredSize(ViewLayoutContext context)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.UpdateItemHeight()
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.OnNeedPaint(Object sender, NeedLayoutEventArgs e)
en ComponentFactory.Krypton.Toolkit.VisualControlBase.PerformNeedPaint(Boolean needLayout)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.OnTreeViewLostFocus(Object sender, EventArgs e)
en System.Windows.Forms.Control.OnLostFocus(EventArgs e)
en System.Windows.Forms.Control.WmKillFocus(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.TreeView.WndProc(Message& m)
en ComponentFactory.Krypton.Toolkit.KryptonTreeView.InternalTreeView.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


My fault. (but that did not occur with regular TreeView)
Pau
 
Posts: 10
Joined: Thu Dec 23, 2010 12:01 am

Re: TreeView Crash

Postby Cocotteseb » Wed Dec 19, 2012 4:54 am

If you have sources in KryptonTreeView.cs, just surround what's inside the method UpdateItemHeight with a
Code: Select all
if (!IsDisposed && !Disposing)
Cocotteseb
 
Posts: 71
Joined: Sat May 31, 2008 6:15 am


Return to Krypton Toolkit

Who is online

Users browsing this forum: Google [Bot] and 3 guests