PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Error when shutdown game

I receive an Unhandled exception when try to shutdown game.
Debugger shows me "delete m_buffer" line in source\surface.cpp
As I can see, it's caused by m_display.reset()
But why?! :)
Post some code to help us see what your doing. Are you checking to make sure the buffer is not NULL before deleting?
Heh, i warned him to post code, but he didn't listen :)
DaGGeR wrote:Heh, i warned him to post code, but he didn't listen :)

As you wish, Raven Dagger...
Code:

class CMAIN: public Game
{
public:
inline void EndGame(void){Shutdown();}
}


Or maybee you need PF sources? :) I can help you with one useful link :D
Oh... I always foget to login 8O
Very resourceful... perhaps you should attach archive with sources of a small project, that generates problem on execution? ;)

Don't use the Force, Luke... Think! :D
If you don't call Update() after a GetDisplay(), it will.

Basically, don't shutdown in the middle of drawing your frame.
So, i suppose it won't hurt to change Shutdown() into somthing like this?

Code:

void Game::Shutdown()
{
m_display.get()->Update();
GameEnd();

m_display.reset();

DestroyWindow();
}
I wouldn't...

I would just be sure to begin each frame with getdisplay, and end each with update.
I use this simple method:
Code:
void Pyromania::GameLoop ()
{
pDisplay = GetDisplay();
pDisplay->DrawAllTheThingsYouWant();
pDisplay->Update();
if (G_BoolExit)
{
Shutdown();
}
}


void Pyromania::Exit(){G_BoolExit = true;}


//Some place in your game
pPyr->Exit();

I had an exceptions many time using pointers and wrong class destructors:
my wrong poiters pointed to the data already allocated for another pointer. And after game ended they tried to deallocate some memory. It was a lot of pain to find it out :cry:
Thanx for replying.
I add Update(), and now it isn't throw exception.
Maybe it's all problem in my hands :)