linux bugs

BlitzMax Forums/MaxGUI Module/linux bugs

Nigel Brown(Posted 2006) [#1]
when trying to access a TGadget.context i get an error "Unhandled Exception:Attempt to access field or method of Null object"?

the following code: shows the problem all works ok under windows?

see below



skidracer(Posted 2006) [#2]
Are you sure you can't get it to crash in windows, I would have thought SelectedTreeViewNode may return null on all hosts. I assume that is what is happening.


Nigel Brown(Posted 2006) [#3]
works as expected under windows, but the problem in linux occurs on the line handle.context=FullPath


Nigel Brown(Posted 2006) [#4]
I guess i didnt make myself clear. Here is the updated code with line that causes problem highlighted!

SuperStrict

Local MyWindow:TGadget=CreateWindow("TreeView Example", 40,40,400,400)
Global MyTreeView:TGadget=CreateTreeView(5,0,200,330,MyWindow)

DebugLog MyTreeView.tostring()

EnumFiles(BlitzMaxPath(),MyTreeView)

'--------------------------------------------------------
Repeat
'--------------------------------------------------------

	WaitEvent()

	Select EventID()
	
		Case EVENT_WINDOWCLOSE
			End

		Case EVENT_GADGETACTION
		
			DebugLog "event id = " + EventID()					' EVENT_GADGETACTION
			DebugLog "event source = " + EventSource().tostring()	' MyTreeView
			DebugLog "event data = " + EventData()				' ?
			DebugLog "event extra = " + EventExtra().tostring()	' Node
'			DebugLog "event text = " + EventText()				' ?
'			DebugLog "event mods = " + EventMods()				' ?

			Local Node:TGadget = SelectedTreeViewNode(MyTreeView)
			Local s:String=String(Node.Context)
			If s>""
				EnumFiles(s,node)
				node.context=""
			EndIf
			ExpandTreeViewNode(node)
			
	End Select

Forever
End


'--------------------------------------------------------
Function EnumFiles:Int(Dir:String, Parent:TGadget)
'--------------------------------------------------------
  Local Folder:Int=ReadDir(Dir)
  Local File:String
  Local FullPath:String

  Repeat
      File=NextFile(Folder)
      If File=".." Or File="." Or File=Null Then
          'Do Nothing
      Else
          fullPath = RealPath(Dir+"/"+file)
          If FileType(FullPath)=FILETYPE_DIR Then
            Local handle:TGadget=AddTreeViewNode(file,Parent,-1)
'********************************************************
            handle.context=FullPath
'********************************************************
          Else
              AddTreeViewNode(file,Parent,-1)
          EndIf
      EndIf
  Until File=Null

End Function





Nigel Brown(Posted 2006) [#5]
skid, I have added some debug code at the point you queried, not sure why you believe SelectedTreeViewNode() should always return null on all platforms? The node is selected at this point.


Brucey(Posted 2006) [#6]
kind of looks like AddTreeViewNode() is returning Null, rather than a node?

Which is strange, cuz it definitely has "return n"

Have you tried adding a DebugStop before you call AddTreeViewNode() and stepped into the code?
Perhaps it's doing something else along the way that isn't immediately apparent?


Brucey(Posted 2006) [#7]
I see what's wrong.

You are passing in the TreeView gadget, where the function is expecting a Node. The TFLWidget (the thing that actually gets passed in as Parent) method InsertNode() does nothing and returns nothing, which is why it breaks.

If you change EnumFiles(BlitzMaxPath(),MyTreeView) to
EnumFiles(BlitzMaxPath(),TreeViewRoot(MyTreeView)), it works.
(should probably work on all platforms too)

Looks like FLTK GUI doesn't work in the same way that win32 GUI does.
If FLTK was more OO then this wouldn't be an issue, as the TreeView itself could have been a kind of "node"...
GTK GUI works in this way, so the code runs fine without the above modification.

HTH