Program hanging on exit...but why?
Posted: Thu Oct 19, 2023 6:48 pm
I'm at a bit of a loss in figuring out what's happening here and hope someone has some insight on diagnosing it.
The code is a bit much to paste here without narrowing down where something is going wrong, so I'll try to describe it as best as I can and post more details if someone can point out where to look.
To start off, there's one source file that at the bottom consists of three statements:
Immediately above that is the definition for LaunchClient().
LaunchClient() defines some protected variables, launches a thread for listening to UDP packets, opens a form and sets some initial settings for that form's values.
It then starts a "Repeat...Until intEvent = #PB_Event_CloseWindow Or intQuit = 1" loop.
I click on the form's "Quit" button, and I see this series of events via Debug:
intEvent = WindowEvent()
intEvent is "PB_EVENT_GADGET"
Case Button_Quit
Locks a mutex, checks some settings from a struct, unlocks mutex.
Sets intQuit = 1
Just before the "Until..." statement, it printed a Debug message to show it exited all the select/if/etc. statements in the loop.
Printed a message that it's out of the Until loop
The next line is EndProcedure
Which then goes to the previously mentioned last three lines of the source code; LaunchClient(), prints "LaunchClient() done", then End. At that point the application hangs with a spinning beach ball and I have to force-quit, and PureBasic comes up with a debugged application unexpectedly quit message.
So something is hanging at the "End", I think? What could PB be doing at that point to close out the application, or where can I get more information on where a loop or error is happening?
The code is a bit much to paste here without narrowing down where something is going wrong, so I'll try to describe it as best as I can and post more details if someone can point out where to look.
To start off, there's one source file that at the bottom consists of three statements:
Code: Select all
LaunchClient()
Debug "LaunchClient() done"
End
LaunchClient() defines some protected variables, launches a thread for listening to UDP packets, opens a form and sets some initial settings for that form's values.
It then starts a "Repeat...Until intEvent = #PB_Event_CloseWindow Or intQuit = 1" loop.
I click on the form's "Quit" button, and I see this series of events via Debug:
intEvent = WindowEvent()
intEvent is "PB_EVENT_GADGET"
Case Button_Quit
Locks a mutex, checks some settings from a struct, unlocks mutex.
Sets intQuit = 1
Just before the "Until..." statement, it printed a Debug message to show it exited all the select/if/etc. statements in the loop.
Printed a message that it's out of the Until loop
The next line is EndProcedure
Which then goes to the previously mentioned last three lines of the source code; LaunchClient(), prints "LaunchClient() done", then End. At that point the application hangs with a spinning beach ball and I have to force-quit, and PureBasic comes up with a debugged application unexpectedly quit message.
So something is hanging at the "End", I think? What could PB be doing at that point to close out the application, or where can I get more information on where a loop or error is happening?