When I run my app with with “Break on Exceptions” enabled, when I click the close window button on the window, it breaks as if there was an exception, BUT there is nothing in the stack trace other than “Event loop”. When I dig around the variables, in Runtime->Contents there is a NilObjectException but the Error Number is 0 and there is no Message. If I resume running the app, it keeps breaking. If do it over and over again (around 10 times!), eventually it doesn’t break, but the window actually never closes and my app is still running…
There is a bit of code in this window’s close event, I’ve set a breakpoint in there but it is never reached. If I disable “Break on exceptions”, the code does get reached however, the window closes as expected.
However, I am trying to get Profiler data and that never shows up in the IDE, which leads me to believe that the app might not be finishing cleanly but rather silently crashing (hence the lack of Profile data).
I’m stumped as to what may be causing this. Kind of hard without a stack track … Ideas !!!
(This is a relatively large app, this is happening in Windows - I don’t have a Mac so I don’t know how it behaves there)
does that bit of code in the close event reference ANY control or property on the window?
I might suggest moving that code the the CANCELCLOSE event instead
Thanks for the reply Dave.
The code in the close event does not manipulate any controls from that specific window, but it does call close on a bunch of other windows. Could that be it ? (I guess I can try it easily enough )
Nope. I commented out all the other windows close calls, and then ALL the code in the close event, still get an exception in the event loop.
I wish someone from Xojo would comment on why I would get an exception in the event loop without any further details… That seems quite strange to me.
Hard to say without seeing the code
A feedback report with your project attached to it privately would aid that
Hmmm, that could be pretty tricky - it’s a fairly complex corporate app with a handful of plugins and several external data dependencies that would not be trivial to get going with…
Can you post just the code from your Close, CancelClose, Activate, and Deactivate events?
I only have code in Close, minimize, open an resized.
Here is the close code
As previously mentioned, even after I commented out all of it, it still threw an exception in the event loop when I click the window close button.
Weird thing is that if I uncheck “Break on exception”, everything works fine and I don’t get the usual Exception dialog. I’m confused. :-/
As an aside, if you’re quitting anyway, why do you need all of those steps?
It’s time to start adding DebugLog items to your methods so you can narrow it down.
[quote=85686:@Kem Tekinay]As an aside, if you’re quitting anyway, why do you need all of those steps?
It’s time to start adding DebugLog items to your methods so you can narrow it down.[/quote]
At some point we had a window hanging around even after the main got closed, keeping the app running… so we just stuck that in there to clean up… Things worked fine (app shutdown, still with exception of course) after I commented them out so they may not be necessary any longer but I don’t think it hurts to have them in there…
Pretty confident it’ll go away if you stop trying to close those implicit instance windows as part of your shutdown process.
Ah, of course, you said you already commented it all out. Silly me, sorry.
Don’t know if this is related, but I give it a shot anyway. I have just ported an app over to 2014r1.1 from 2012r2.1 and had the exact same problem. The culprit was the Database.Close() command that took some time to complete and probably broke many things.
My solution was to close the database in CancelClose, set a flag, start a 250 ms timer and from the time close the window “again” as the flag is now set.
I read somewhere that the database actions were now lifted off to a separate Thread. Threads and closing windows are a nasty combo.
Thanks Mattias. I did give this a try but no joy.
That being said, for whatever reason even tho the exception in the event loop still occurs, Xojo now has started giving me profiling data regardless. It’s pretty weird and buggy - it didn’t before - but I got what I was after originally…
I have a similar problem. Previously, these errors were not. Now, I do not know whether because of the large program. When closing windows, reporting the error.
Example: Closing a window Oprogramu and return to the main window Tarok:
if viz_s = 0 then exit
viz_s = 0
CAK1 = 1
while CAK1 = 1
oprogramu.close / / here is a red beetle
App.DoEvents is not to be used in Desktop applications. It is for ConsoleApplications only. See Application.DoEvents.
Philippe Tanguay , can you determine what failed? Due to excessive program?