Is there any way of forcing GLB to finish writing an ini file before it quits? I have noticed that on occasions when I quit a program that just happens to be writing to the ini file while quitting it corrupts it and is then recreated when the program is loaded next time zeroing everything stored
In my experience, this has never happened. This is how I normally do it - and it works fine. Example attached. I've used this method to write over 3000 lines to an ini on close without fail. Let me know how it works for you.
[attachment deleted by admin]
Well, you could put code in the GLB_ON_QUIT() routine to detect if your file is still being written.
Us a global flag such as 'isWritingIni' and set this to TRUE at the start of ini writing and to FALSE when done.
Then in the GLB_ON_QUIT() routine check this flag, and if TRUE, try calling the function again to rewrite the ini file.
I think what happens is that your file will be in the middle of writing, a request will come to GLB to quit (by clicking the 'X' for example), GLB stops all other code from running and triggers the GLB_ON_QUIT() routine for you to finalize your code or to save any changes (without user interaction).
So in your case you'll be in the middle of storing the ini, and GLB will interrupt you and transfer the code to the GLB_ON_QUIT routine. By using the global variable above to detect that you were in the middle of saving, you would then have to resave the ini once more.
Glb-on-quit is called from within showscreen or hibernate. Android might be an exception. I'll have to fix that still. So, corruption is pretty much impossible. Got code?
What platform does this happen on?
Quote from: Kitty Hello on 2011-Jun-10
Glb-on-quit is called from within showscreen or hibernate. Android might be an exception. I'll have to fix that still. So, corruption is pretty much impossible. Got code?
I can only send the whole project Kitty. It is not something that happens all the time, infact its a very infrequent occurence and may not be related to the INI file being written to when a shutdown happens, I just wanted to eliminate that as a possiblity.
Thanks everyone for the tips, I will try adding in a backup routine in GLB_ON_QUIT to start with