There's a leak in PocketFrog that shows up when the library is started and stopped more than once within the same instance of an application.
I've made a game based on PocketFrog. I've also made a level editor for the game. The level editor runs on Win32 and I'm using the amazing feature of PocketFrog that enables the same code to run both on PocketPC and Win32 to also run my game from inside the level editor. The idea is to let the player test the level he is working on without leaving the level editor or having to move the level file over to a PocketPC device.
Everything works the first time the game is started from the level editor. But if the user closes the game and then starts it again, the game fails to start. This is even though I instantiate the entire game on the stack and let it fall out of scope each time the user ends it.
It looks like Thierry is aware of the problem because I have found the following in the PocketFrog code:
<b>PocketPC.cpp</b>
Also, in the same file, there's an InitDrivers function that starts like this:
The second time the game is started, the function returns immediately, as if the drivers are already initalized. But at this point the drivers have been released and should be initalized again.
However, I'm unable to fix this because the only place that I can find that l_displayDriver and l_inputDriver pointers are ever initalized is further down in the same function:
But of course, that's after the pointers have been tested so they have to be initalized somewhere else as well. They are both declared in an anon namespace.
Anyone know how to resolve this issue?
Thanks,
Roger Dahl
I've made a game based on PocketFrog. I've also made a level editor for the game. The level editor runs on Win32 and I'm using the amazing feature of PocketFrog that enables the same code to run both on PocketPC and Win32 to also run my game from inside the level editor. The idea is to let the player test the level he is working on without leaving the level editor or having to move the level file over to a PocketPC device.
Everything works the first time the game is started from the level editor. But if the user closes the game and then starts it again, the game fails to start. This is even though I instantiate the entire game on the stack and let it fall out of scope each time the user ends it.
It looks like Thierry is aware of the problem because I have found the following in the PocketFrog code:
<b>PocketPC.cpp</b>
- Code:
DisplayDriver* l_displayDriver; //fixme: leak at exit
InputDriver* l_inputDriver; //fixme: leak at exit
Also, in the same file, there's an InitDrivers function that starts like this:
- Code:
bool InitDrivers( HWND hwnd )
{
// Check if the drivers are already initialized
if (l_displayDriver && l_inputDriver)
return true;
The second time the game is started, the function returns immediately, as if the drivers are already initalized. But at this point the drivers have been released and should be initalized again.
However, I'm unable to fix this because the only place that I can find that l_displayDriver and l_inputDriver pointers are ever initalized is further down in the same function:
- Code:
std::auto_ptr<DisplayDriver> display( new Win32Display );
std::auto_ptr<InputDriver> input( new Win32Input );
But of course, that's after the pointers have been tested so they have to be initalized somewhere else as well. They are both declared in an anon namespace.
Anyone know how to resolve this issue?
Thanks,
Roger Dahl