Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 6, 2009, 9:42:58 PM (15 years ago)
Author:
landauf
Message:

Attempt to fix a crash when switching from a level back to the mainmenu

Location:
code/branches/core5/src/modules/overlays/hud
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/overlays/hud/ChatOverlay.cc

    r5831 r5895  
    5858    ChatOverlay::~ChatOverlay()
    5959    {
     60        for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it)
     61            delete (*it);
    6062    }
    6163
     
    8789        COUT(0) << "Chat: " << text << std::endl;
    8890
    89         new Timer(this->displayTime_, false, createExecutor(createFunctor(&ChatOverlay::dropMessage, this)), true);
     91        Timer* timer = new Timer();
     92        this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
     93        Executor* executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
     94        executor->setDefaultValues(timer);
     95        timer->setTimer(this->displayTime_, false, executor, true);
    9096
    9197        this->updateOverlayText();
    9298    }
    9399
    94     void ChatOverlay::dropMessage()
     100    void ChatOverlay::dropMessage(Timer* timer)
    95101    {
    96102        if (this->messages_.size() > 0)
    97103            this->messages_.pop_front();
    98104        this->updateOverlayText();
     105        this->timers_.erase(timer); // the timer destroys itself, but we have to remove it from the set
    99106    }
    100107
  • code/branches/core5/src/modules/overlays/hud/ChatOverlay.h

    r5738 r5895  
    5555        private:
    5656            void updateOverlayText();
    57             void dropMessage();
     57            void dropMessage(Timer* timer);
    5858
    5959            float displayTime_;
     60            std::set<Timer*> timers_;
    6061    };
    6162}
Note: See TracChangeset for help on using the changeset viewer.