View previous topic :: View next topic |
Author |
Message |
Andrew Rowley
Joined: 24 Dec 2005 Posts: 63
|
Posted: Mon Feb 09, 2009 2:17 am Post subject: Crash when trying to create drill through function |
|
|
I have a tree where I am using the CellClick event to implement a drill through function, where I open another report to show related data.
In the drill through function I Dispose() the original tree to free the memory occupied by the data. All seems to work, except when the clicked row is selected first i.e. highlighted. Then I get the following crash:
Stacktrace:
at Infralution.Controls.VirtualTree.VirtualTree.UpdateWidgets()
at Infralution.Controls.VirtualTree.VirtualTree.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.PerformLayout()
at Infralution.Controls.VirtualTree.VirtualTree.SetFocusRow(Row row, Boolean ensureVisible)
at Infralution.Controls.VirtualTree.VirtualTree.set_FocusRow(Row value)
at Infralution.Controls.VirtualTree.RowWidget.OnMouseSelection(MouseEventArgs e)
at Infralution.Controls.VirtualTree.RowWidget.OnMouseUp(MouseEventArgs e, Boolean enableDragSelect)
at Infralution.Controls.VirtualTree.RowWidget.OnMouseUp(MouseEventArgs e)
at Infralution.Controls.VirtualTree.CellWidget.OnMouseUp(MouseEventArgs e)
at Infralution.Controls.WidgetControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Infralution.Controls.BorderedControl.WndProc(Message& m)
at Infralution.Controls.VirtualTree.VirtualTree.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Message=Object reference not set to an instance of an object.
I guess after the tree is disposed it tries to update the clicked row to remove the highlight. Is there any way to get around this error?
Thanks
Andrew Rowley |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Feb 09, 2009 8:23 am Post subject: |
|
|
Trying to dispose of a control from inside an event handler called by that control is a pretty hairy thing to do - not many controls will survive that. Virtual Tree is actually very light on resource consumption compared to most other trees so I would doubt that you need to be so concerned about disposing of it straight away. If you really think this is necessary then I would probably use a start a timer from the CellClick event and then dispose of tree in Timer.Tick event handler. _________________ Infralution Support |
|
Back to top |
|
|
Andrew Rowley
Joined: 24 Dec 2005 Posts: 63
|
Posted: Mon Feb 09, 2009 9:25 pm Post subject: |
|
|
It's not the tree that is the main problem its my data. I am using trees to view collections that are probably tens of MB and potentially hundreds of MB. (I am very happy with the way the tree performs BTW). I programatically create the trees and add them to panels for display.
I tried clearing the data source but that resulted in the same problem. I also tried just removing the tree from the panel and hoping it would be garbage collected naturally, but it seemed like something in Windows Forms kept a reference to it.
Your timer suggestion is probably best, that should allow me to handle it OK.
Thanks |
|
Back to top |
|
|
|