GLB_ON-QUIT not executing on program termination

Previous topic - Next topic

AlienMenace

Reposting from the GLBasic - en forum...

It seems I am having an issue with GLB_ON_QUIT not being called in my iPhone app. I have fast task-switching enabled (GLB_ON_PAUSE/GLB_ON_RESUME) and working good but the program just won't run the GLB_ON_QUIT subroutine when I exiting the program (killing it while paused from the fast-task switch panel). However GLB_ON_QUIT seems to be executing on Windows Ok.

I have ALLOWESCAPE FALSE and AUTOPAUSE TRUE at the top of my code and my main loop is setup this way:

WHILE TRUE

WEND
END

Is this enough or do I need to add something else or is this a bug? I am stumped.
Thank you.
Apps published: 3

AlienMenace

Here is some additional info:

I have a stdout messaging for debugging:

SUB GLB_ON_QUIT:
STDOUT "on quit\n"

When the program quits on the xcode debugger, here is the text from the console:

[Switching to thread 13315]
Status: 0
-applicationWillResignActive   -> pause
on pause
-applicationDidEnterBackground -> pause
[Switching to thread 11779]
Program received signal:  "SIGKILL".
warning: Remote failure reply: E25
(gdb)

I am not getting the stdout message from the GLB_ON_QUIT sub in the console.  :'(
Apps published: 3

AlienMenace

I basically have those subs setting and unsetting variable flags to control program flow to essentially place my program in a "paused" state with regard to my main loop not updating things that i don't want updated during this time... but, in any event you still need to have the opoortunity to write data or release memory when the program actually ends so in my mind, it is essential in this day and age of iOS 4 that both things are working.

Thanks!
Apps published: 3

Kitty Hello

Again - mentioned in another tread - when you kill a program with iOS "task manager", the program get's pkill'ed - no way to react on that.
So write data on both: GLB_ON_PAUSE and GLB_ON_QUIT. Do not rely on which is called.

AlienMenace

#4
Okay, that makes sense. It would be great to see this kind of information in the FAQ or a knowledge base of some sort. The problem with this method though is when do you unload graphics and sound when the program may be resumed after pause? Do you have to just reload everything on GLB_ON_RESUME?

Thanks for the reply, Kitty.
Apps published: 3

Kitty Hello

No. On ON_RESUME, you have all the game data still in memory. Just continue.

AlienMenace

Yeah, I understand that... but how do you unload graphics and sound if GLB_ON_QUIT is never called? If you unload graphics and sound on GLB_ON_PAUSE then the data will not be there when GLB_ON_RESUME is called. Do you see what I mean?

Thanks Kitty.
Apps published: 3

ampos

Nothing is unloaded from memory eith GLB_ON_PAUSE or RESUME. your program is just sent "back" and  "paused".

Also, you dont need to unload anything when your program is "GLB_ON_QUIT". The memory reserved by sprites and such on your program is "freed" by the Operatin System.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Slydog

If your program enters a 'GLB_ON_PAUSE()' state, that means the user switched apps, or 'closed' your app by clicking the home button.  Or am I mistaken?

Therefore a game entering a pause state may never get resumed if the system decides that it needs your memory and removes it?

If so, then you should also save your game state data during a pause, and restore it again during a resume.
Make the 'SaveGameState' a common function and call it from both 'GLB_ON_PAUSE()' and 'GLB_ON_EXIT()' to be sure to catch it.
(Plus the opposite 'LoadGameState')
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

ampos

check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE