Beispiel #1
0
  void StateManager::cleanup(void)
  {
    // Always call our cleanup events with our pointer when this method is called
    mCleanupEvents.doEvents();

    // Remove one of our dead states
    if(!mDead.empty())
    {
      // Retrieve the dead state
      IState* anState = mDead.back();
      assert(NULL != anState && "StateManager::handleCleanup() invalid dropped state pointer");

      // Pop the dead state off the stack
      mDead.pop_back();

      // Call the DeInit if it hasn't been called yet
      if(anState->isInitComplete())
      {
        anState->deInit();
      }

      // Handle the cleanup before we delete anState
      anState->cleanup();

      // Just delete the state now
      delete anState;

      // Don't keep pointers around we don't need
      anState = NULL;
    }

    // Make sure we still have an active state
    if(NULL == mStack.back())
    {
      // There are no states on the stack, exit the program
      if(NULL != mApp)
      {
        mApp->quit(StatusAppOK);
      }
    }
  }