[Gambas-user] Program going off the rails in a way I can't explain. Help?

Bill Richman bill at ...2351...
Mon Jan 18 15:23:19 CET 2010


I've got a really weird problem going on.  I've been working on this
project for about a month, and today I decided to make some major
changes to the user interface operates.  I moved some code around and
delete some code, and now when I run it in the IDE, it randomly jumps
into the sub that handles the click event for a combo-box control called
cbBedList_Click().  The routine "Populate_cbBedList()" gets called by
"Form_Open", and reads values from a database to populate the
Combo-box.  As far as I can remember, I haven't changed the code for
this form at all, but seemingly for no reason, when it hits line "178
cbBedList.Clear" in the Populate sub, it starts executing the code in
cbBedList_Click!   This generates an error because the cbBedList.index
value isn't set, since it wasn't actually clicked.  If I remark out the
contents of the Click event, the Populate routine finishes, although I
still see the debug statement from line 169.  If I remark out everything
from 168-173, it still runs fine (although obviously I don't get click
events handled for the combo-box any longer!).  I'm pulling my hair
out.  The stack backtrace shows:

FMain.cbBedList_Click.169
(native code)
FMain.Populate_cbBedList.178
FMain.Form_Open.26

Setting a breakpoint at 178 and single-stepping shows exactly what the
backtrace does; the next line to be executed after 178 is 169!  ANY
ideas???  Please?

===


168 PUBLIC SUB cbBedList_Click()
169 DEBUG "We're in cbBedList_Click()!"
170 '  BedNum = BedList[cbBedList.index + 1]
171 '  DrawPlots($db, BedNum)
172
173 END
174
175 PUBLIC SUB Populate_cbBedList()
176  DIM sql AS String
177  'populate the bed selection listbox
178  cbBedList.Clear
179  sql = "select bedname, bednum from Beds"
180 $res = $db.Exec(sql)
181  DEBUG "$res.Count=" & $res.Count
182  FOR EACH $res
183    DEBUG "$res!BedName=" & $res!BedName
184    cbBedList.Add($res!BedName)
185    DEBUG "cbBedList.count=" & cbBedList.Count
186    DEBUG "$res!BedNum=" & $res!BedNum
187    BedList[cbBedList.count] = $res!BedNum
188  NEXT
189 END

-- 
Bill Richman - Lincoln, Nebraska
Tilter at windmills, maker of pies in the sky, & curmudgeon
email: bill at ...2350...  web: www.geektrap.com







More information about the User mailing list