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

Charlie Reinl Karl.Reinl at ...2345...
Mon Jan 18 16:39:06 CET 2010


Am Montag, den 18.01.2010, 08:23 -0600 schrieb Bill Richman:
> 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
> 

Salut Bill,

first question  : which gambas 2 or 3 ?
second question : did you update that gambas ?
third question : did you try to make a ALT-F7 (compile all) in the IDE ?

there was said something about fired event by code, look in the archive.

As workaround, you can set a bIsPopulate which is set to FALSE between
line 177 - 178 and to TRUE  after the Next.

And in cbBedList_Click you don't do anything  if NOT bIsPopulate .

-- 
Amicalement
Charlie





More information about the User mailing list