Bugfix in wxCodeGen

BlitzMax Modules Forums/Brucey's Modules/Bugfix in wxCodeGen

Hello, I created a dialog in wxFormBuilder that made wxCodeGen hang when generating the code due to wxBitmapButtons. The problem was in the "DoBitmap" method in code_gen.bmx because of an array index out of bounds. I just added a check for this and it seems to work ok now. [edit] but may not be generating the code properly. I thought maybe it was trying to load bitmaps for unused things like onFocus, but maybe not. Anyway too late to check further now, will check tomorrow!

	Method DoBitmap:String(bm:String)

		Local text:String = ""
		
		Local bitmap:String[] = bm.Split(";")
		text:+ "wxBitmap.CreateFromFile(~q" + bitmap[0] + "~q, "
		If bitmap[0]
			Local kind:String = bitmap[0].Split(".")[1].ToUpper()
			Select kind
				Case "PNG"
					text:+ "wxBITMAP_TYPE_PNG"
				Default
					text:+ "wxBITMAP_TYPE_ANY"
			End Select
			
			text:+")"
		End If
		
		Return text
	
	End Method


Ahh I think I know why, in the form builder I had set up a bitmap to show when selected, but then changed my mind and got rid of it but codegen still tried to load it even though it was just a blank string "". Looking at the fbd file there is "<property name="selected">; Load From File</property>" so it looks like the form builder doesn't properly clear it or something.

Ah, yes. Formbuilder has the habit of not emptying the property once you've set something and then unset it. Looks like I missed one :-)

I think, if not bitmap[0], then it can probably just return "Null", which should get around it trying to load anything at runtime.