Sometimes, when I quit my app, it hangs. I have a feeling that I haven’t closed something out properly but for the life of me I cannot find it. I can’t pause in the debugger when the app is hung. Attempting that just doesn’t work. I’ve put break points all the way down to app.quit and everything that I can find in the debugger has been properly closed out.
I’ve got a hanging reference somewhere, but just can’t find it and it’s driving me nuts!
Suggestions on how to find it?
i get something like that, that drives me nuts at least once a week. hence why I dont have any hair left.
I dont know how to figure out your issue. Sorry.
It would be handy to know which platform and whether youre using a vm, etc…
It was happening on both Windows and Mac but seemed like every time on Windows (on the Mac it was occasionally happening). I wasn’t even making it to the close event. It was hanging somewhere between App.CancelClose and App.Close.
But I pulled just about all my code to remove things and clean up from the App.Close event and put it in App.CancelClose. The problem went away.
I used to get hit with this pretty regularly, too. Finally I started putting code in my Close event handler to kill any thread that might still be running and to close any window that might be open, visible or not.
[code]// clean up any open windows
For i As Integer = WindowCount - 1 DownTo 0
If Window(i) <> Nil Then Window(i).close
if Thread1.State < 4 then Thread1.Kill // repeat for all threads
Also, be sure to close any open database that has a file associated with it and, for that matter, any other file you may have opened.
I know that some of these are supposed to be handled automatically by Xojo when the item in question goes out of scope but I like making sure. Old habits die hard.
Oh I do all that. I had all the “destructor” code in the close event of the app. Something was hanging between the App.CancelClose and App.Close events.
Moving all the destructor code to the App.CancelClose event solved the problem so far 100%.
I’ve recently had a similar situation. What I did on macOS to figure out which call is causing the problem:
- let the app “hang”
- force-quit the app
- macOS generated a CrashReport
- locate and read it…
It hasn’t been that difficult to see which last code-call was the culprit.
While I’m glad you’ve found a solution - doing this “debug via CrashReport” might help someone else one day in a situation where the IDE-Debugger isn’t much help.
Yeah, I tried that too. It pointed to the fact that I attempted to quit the app from the quit menu item. I agree the crash report can tell you some things but this time it was less than helpful…
Here’s a crash report I pulled from console so you can see:
19 main + 19 (MediaSwitcher + 126133107) [0x10f14d373]
19 _Main + 324 (MediaSwitcher + 126151156) [0x10f1519f4]
19 REALbasic._RuntimeRun + 19 (MediaSwitcher + 1647683) [0x107a95443]
19 Application._CallFunctionWithExceptionHandling%%o<Application>p + 285 (MediaSwitcher + 552029) [0x107989c5d]
19 mainWindow.mainWindow._FileQuit_Action%b%o<mainWindow.mainWindow> + 100 (MediaSwitcher + 41219124) [0x10a052434]
19 REALbasic.Quit%%i8 + 11 (MediaSwitcher + 1640507) [0x107a9383b]
Process: MediaSwitcher 
19 main + 19 (MediaSwitcher + 126133107) [0x10f14d373] 1-19
19 _Main + 324 (MediaSwitcher + 126151156) [0x10f1519f4] 1-19
19 REALbasic._RuntimeRun + 19 (MediaSwitcher + 1647683) [0x107a95443] 1-19
19 Application._CallFunctionWithExceptionHandling%%o<Application>p + 285 (MediaSwitcher + 552029) [0x107989c5d] 1-19
19 mainWindow.mainWindow._FileQuit_Action%b%o<mainWindow.mainWindow> + 100 (MediaSwitcher + 41219124) [0x10a052434] 1-19
19 REALbasic.Quit%%i8 + 11 (MediaSwitcher + 1640507) [0x107a9383b] 1-19
19 ThreadWithFinishedEvent.Event_Run%%o<ThreadWithFinishedEvent> + 1126 (MediaSwitcher + 38377526) [0x109d9c836] 1-19
19 ThreadPoolManager.Event_Run%%o<ThreadPoolManager> + 778 (MediaSwitcher + 63548890) [0x10b59ddda] 1-19
19 Thread.Suspend%%o<Thread> + 11 (MediaSwitcher + 405755) [0x1079660fb] 1-19
0x107903000 - 0x10f23efff com.justaddsoftware.mediaswitcher 4.0.1 (220.127.116.11.466) <6D3A221E-5B3F-3C09-8848-79E40F3C0718> /Users/USER/Documents/*/MediaSwitcher.app/Contents/MacOS/MediaSwitche
It could be a bug in XOJO. I found a bug that I haven’t filed in a textarea and bolding text with sellength and the start being less than zero. Sorry for being obscure but it plays havoc with formatting and also won’t let the system close