Need help with click error on a list box

I’m not sure how to describe the problem I’m having but here goes
I have a listbox with any number of items in it.
I click on an item and most of the time in works OK, BUT every so often maybe 1 in 10 tries I click on an item in the program and it crashes.

I Really need to find out what is happening because this same problem is happening in all my programs that have a listbox in them. It evens happen on other computes. So this is really a big problem for me.

I have tried to find out what is happing by using the following code in the listbox change code
TRY
change code
CATCH
message “BAD MOUSE CLICK TRY AGAIN”
END

I also tried the same code in the mouse down code
In either case when the program crashes I do NOT get the message. (It’s like the program crashes before it can get to the code)
What am I doing wrong!!! I need to find out what is happening and find a work around.

Any help will be apricated
Dave

PS I’m running windows 10 if that helps. I think it happens when I click between items in the list but can’t prove it one way or the other.

Is it an exception or a crash?

If it crashed, what does the crash log say?
If it’s an exception, what kind of exception? What line of code does it stop on?

I don’t know what it is.
The program just closes and drops me back to the IDE? (back to where I write/edit the program).
It’s just like I loaded the program just before I hit the run button. There is no other indication that I can see.

Sorry I’m not up on the termination and don’t know what else to look at.
Dave

That sounds like a crash, so it’s not something easy like an OutOfBoundsException. The crash logs might help give you an idea where to start looking.

do you use the built-in method “quit” in your program ?
if yes , search for all of them and add a breakpoint on each line
see if it stops there after the crash.

I have only 1 quit in my program. When the error occurs my code sheet stops at the quit command where I have the breakpoint
does this help I’ve never done anything with breakspoint so I don’t what to do next.

I always use the command message “Here at quit” just before my quit command.
I hope this is helping
Dave

Do you have an unhandled exception event handler on the app?
Stick some logging code and/or a breakpoint there.

do you have ‘break on exceptions’ turned on while debugging?

Do you check that the row is a number less than the listcount in the change event?

Its probably just an out of bounds exception that isnt handled.

[quote=443925:@David Howe]I have only 1 quit in my program. When the error occurs my code sheet stops at the quit command where I have the breakpoint
does this help I’ve never done anything with breakspoint so I don’t what to do next.

I always use the command message “Here at quit” just before my quit command.
I hope this is helping
Dave[/quote]

some help here : https://documentation.xojo.com/getting_started/debugging/debugger_usage.html

in the bottom left of the pane, you have the stack. there you can see where the program comes from, and if you clic on each of the lines in the stack you see exactly where the program was lead to the quit command.

Edit (Paul): Switched in URL to documentation.xojo.com

I’m sorry guys when the program crashes or stops it does not stop at the breakpoint.
also list box has 3 cells in each line in the list box. Could that be the problem?

Dave

make it a 2 cells or 4 cells for test purpose. and see if it continues crashing or not.

I went from 2 cells to 3 cells and it still fails.
Dave

Do you use an anti-virus anti-malware program? I had very similar problems (not with a listboxes) where the debug app would simply close unceremoniously. Once I registered the debug app as safe with BitDefender, I never had the problem again.

Interesting that maybe the problem. I have Norton but don’t know what the debug app would be and I as far as I know I don’t have Bitdefender either.

Dave

I used to use Norton. I am pretty sure it has the same feature - it monitors active apps for suspicious activity, whatever that is. Use the Norton configuration settings to disable the malware detection and then run the Xojo app again. At least that will tell you if Norton is the problem.

I unhooked the internet and turned off all the anti-virus and firewalls and exploit prevention off. Still have the problem.

But did I need to turn off any windows security too?
Dave

Listbox (Row, Column, ListCount, etc.), Arrays, etc. returns or use 0-based values.

Overall, without seeing real code how can we guess the correct anwser ?

Are you working in a built module or in the IDE? If in the IDE, set a breakpoint before it crashes, and then step through line by line until it crashes, and then you know the offending line.

Are you using a thread, timer, or other background process that could be running at the same time and that could be crashing the program? If so, deactivate them and see if the crash still occurs.

Are you using a lot of memory (images or videos)? A Xojo app will crash without warning if you run out of total system memory.

I’m using the IDE and have 12 Gigs of memory.
I’ve used the TRY command as the first line in the CHANGE function of the Listbox and on the mouse down & up and it never gets there. (see my original question)
The problem with using a breakpoint is that the failure only happens once in a while maybe 1 in 25 tries.

as far as “Overall, without seeing real code how can we guess the correct answer ?” is concerned I’m not sure what you mean by real code.

It’s like it fails when I click on an item in a listbox and never gets to any code thereafter (Not exception, or TRY or even a Message statement. ) Is there anywhere else I can put the TRY command or Message command? or is there an ON ERROR command?

Like I said before any ideas will be greatly apricated as I’m not the brightest bulb around.
Thanks
Dave

PS As far as I know I’m NOT using a thread, timer, or other background process that could be running at the same time.

It is worth knowing if the program is even reaching the code in your ListBox event handler.

Consider putting something like this at the beginning of your MouseDown (or other event handler you are using) code:

[code]STATIC RunCount AS INTEGER = 0
RunCount = RunCount + 1
DIM d AS NEW Date
DIM Now as STRING = d.LongTime

DIM f AS FolderItem = GetFolderItem (“SomeFileName.log”)
IF f <> Nil THEN
DIM t AS TextOutputStream = TextOutputStream.Append (f)
t.Write Now + " (" + Str (RunCount) + “)” + EndOfLine
t.Close
END IF[/code]

Choose an appropriate path and file name for SomeFileName.log.

Monitor the log file. Especially keep track of the number of times you click, and check if the log file agrees with the number of Event responses. If the code does not even run on the cycle that the app crashes, then you probably have a compiler bug. If the event response runs before the crash, then move the above code down, after a few lines of “real” code in your event handler, until you find the offending line of code.

Without seeing the actual code, we’re all guessing here so let’s clear up a few specifics to help us (me) focus.

  1. You said you’re on Windows 10. What version Xojo are you using?
  2. Since you said it happens in all your programs that have a listbox in them and on other computers, I assume that you built the App and moved the executables and Libs to the other machines. Perhaps the Xojo installation is somehow munged. Have you removed it and reinstalled from a freshly downloaded copy? Remove any 3rd party plugins, scripts, etc., that you may have.

If you have done the above without success …
3. You say “when I click on an item…” what are you clicking on? Are you clicking on the listbox header, a cell in a row, in the space below the last row?
4. If you are clicking on a cell, does the app just select the row or are you opening the cell for editing? (Calling EditCell?)
5. Does the crash happen when a cell is selected and you click on another cell in the listbox in the same row? Or in a different row/column? Or in the free space below the last row? Or someplace outside the listbox?

Lastly,
6. Try starting a new, blank project with nothing in it and, from the IDE’s Control Library, add only a listbox to the main window. Add a few rows of data in the Listbox’s Open event. Run it and go on a clicking spree. Does the problem still occur? If so, revisit item #2.