[WIN32Lib] TreeView pblm: erase, addTVItem, & getTVSelectedText cause crash

new topic     » topic index » view thread      » older message » newer message

Derek is already looking into this for me, but I thought I'd see if anyone
else had any ideas about it too.

I'm having a problem in using TreeView, whereby if I erase and repopulate a
TV, *after* I have selected an item in the TV, my program crashes.  If I
remove the "erase" function for the items that I have before the repopulate,
no crash (but dupl stuff in TV).

Program apparently crashes *while* it's repopulating the TV, but inside a
*separate* "onChange" routine, involving getTVSelectedText, as if two
unexpected things are occurring:
1.  maybe the index of "selected item" isn't being reset by the "erase"
function;
2. and maybe "onChange" is being activated during the "addTVItem"?

Here's what I have:
1.  a button which opens a file, reads it in, puts stuff from it into TV;
2.  an "onChangeTV" routine, which copies item selected from TV into
clipboard.

CRASH occurs if I:
1.  open & read file, populate TV,
2.  select an item in TV,
3.  open new file, read & populate TV (this is *when* the crash occurs)

but the failure is indicated as happening in the *"onChangeTV"* routine, in
the function "getTVText", as if the act of repopulating the TV is triggering
an "onChange" event, AND even though I put in a test for TV content (really
test for
item selection) in the "onChange" routine, just to be careful.

There is no problem if I just repeat opening files & populating the TV, as
long as I don't ever *select* anything from the TV; but if I select anything
and *then* open a file & read data from it into the TV, crash.

-----------------------------------

Here's some relevant code:

-- already read in file; now put items in var "AllRoutines" into TV:
  --<snip beginning>
 eraseItems(TreeView5)   -- <== removing this makes not crash, but dupls
items
 for n = 1 to length(AllRoutines) do
     folders &= addTVItem ( TreeView5, 0, 0, AllRoutines[n][1], 0 )--
section names
           for m = 1 to length(AllRoutines[n][2])   -- routine names
          dummy &=
               addTVItem ( TreeView5, 0, 0, AllRoutines[n][2][m],
folders[n] )
     end for
 end for

    current = getTVIndex( TreeView5 )

if current > 0 then -- if anything in TreeView (anything selected):

  if ( (match("procedure", getTVSelectedText ( TreeView5 ))= 1)  --<== fails
here
          or (match("function", getTVSelectedText ( TreeView5 ))= 1))


And here's the first portion of the error message:
C:\Euphoria\Win32Lib\Win32lib.ew:6213 in function getTVText()
subscript value 41 is out of bounds, reading from a sequence of length 0
    iItem = 41')'

... called from C:\Euphoria\Win32Lib\Win32lib.ew:6222 in function
getTVSelectedText()
    id = 8
    sel = 41')'

... called from C:\Euphoria\Win32Lib\Rdx2e9xa.exw:274 in
procedure TreeView5_onChange()
    current = 41')'
    void = 1
    dummy = <no value>


Anyone have any thoughts??

Dan Moyer
(Topica yuck!)

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu