Exit() method in of 0.8.0 windows version, where? I want to save

Hi…,

when my of 0.8.0 windows program is closed, I want to save some things (game status).

Where to call my save method? I don’t find the exit() method like in ios.

Thanks

Michael

just add an exit function in testApp it’ll get called when the app is about to finish

Declare it in your ofApp/testApp header and then implement it in the cpp. You’ll be calling ofBaseApp::exit()

Hi arturo and chuckleplant,

thank you very much, that worked very well at first.

Now I try to save my program status in a file. After starting the program twice I get the attached error:

Here the write code in the exit() method, which runs without exception:

//--------------------------------------------------------------
void testApp::exit(){

	writeFile.open("status.txt", ios::out | ios::trunc);
	if (writeFile.is_open())
	{
		if ( !writeFile.write( (char*) &myGame, sizeof(myGame)))
		{
			cerr << "Fehler beim Schreiben!" << endl;
		}
		writeFile.close();
	}

}

Any ideas?

Thanks

Michael

is it crashing at exit or at the start?

Hi zach,

after exit(), perhaps it is caused by some clean up stuff. Attached the debugger position where it stops.

Thanks

Michael

Hi all,

I am not sure why my save example doesn’t run through without problems, so then I’ve tried the xmlExample in Visual Studio 1012 Express and got also the attached error.

I am somehow helpless

Thanks

Michael

Hi…,

I have attached my simple source code for testing.

src.zip (1.8 KB)

Also I’ve started the debugger again, and found the attached error in the ofEvents.cpp:

Thanks

Michael

Hi…,

I’ve tested this now with the latest build from today (06.Feb.2014) without success.

Has some an idea what I am doing wrong?

Thanks

Michael