MaxGUI Updates Discussion Thread

BlitzMax Forums/BlitzMax GUI Programming/MaxGUI Updates Discussion Thread

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

From what I remember, the only case where a TWindowsTreeNode's _parent would be Null is if you were freeing the node twice, which isn't encouraging as it means that MaxIDE CE must still be keeping a pointer to the node once it has been freed.

I haven't noticed this problem with the official MaxIDE, but it should probably fail silently instead (just in case).

As such, it would probably be better if we just test whether _parent is Null as this will, in itself, determine whether the node has been freed previously.

Therefore can I suggest the following instead:

	Method Free()
		If Not _parent Then Return
		'Avoid firing events when freeing a treenode that is selected.
		If SendMessageW(_tree,TVM_GETNEXTITEM,TVGN_CARET,0) Then DeSelect()
		'Free treenode
		If _item Then SendMessageW(_tree,TVM_DELETEITEM,0,_item);_item=0
		'Redraw parent if we were its last child node
		If Not SendMessageW(_tree, TVM_GETNEXTITEM, TVGN_CHILD, _parent._item) Then _parent.RedrawNode()
		'Cleanup variables that could be circular references
		_parent = Null;_tree = 0;_SetParent Null
		'Release any handle we created using HandleFromObject() in Spawn()
		If _handle Then Release _handle
	EndMethod
klepto: Can you please confirm that this works in the case of MaxIDE CE before I commmit it?