Beispiel #1
0
  StateManager::~StateManager()
  {
    ILOGM("StateManager::dtor()");

    // Drop all active states
    while(!mStack.empty())
    {
      // Retrieve the currently active state
      IState* anState = mStack.back();
 
      // Pop the currently active state off the stack
      mStack.pop_back();

      // Pause the currently active state
      anState->pause();

      // De-initialize the state
      anState->deInit();

      // Handle the cleanup before we pop it off the stack
      anState->cleanup();

      // Just delete the state now
      delete anState;

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

    // Delete all our dropped states
    while(!mDead.empty())
    {
      // Retrieve the currently active state
      IState* anState = mDead.back();

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

      // Pause the currently active state
      anState->pause();

      // De-initialize the state
      anState->deInit();

      // Handle the cleanup before we pop it off the stack
      anState->cleanup();

      // Just delete the state now
      delete anState;

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

    // Clear pointers we don't need anymore
    mApp = NULL;
  }
Beispiel #2
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);
      }
    }
  }