Fix the assert when quitting.

This commit is contained in:
King_DuckZ 2014-07-31 12:00:29 +02:00
parent 0bdaa63db1
commit 1037e2e141
3 changed files with 21 additions and 1 deletions

View file

@ -22,6 +22,12 @@
#include <cassert>
namespace cloonel {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
Mover::~Mover() noexcept {
m_placeables.RemoveAll();
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void Mover::Update (float parDelta) {

View file

@ -35,7 +35,7 @@ namespace cloonel {
};
Mover ( void ) = default;
virtual ~Mover ( void ) noexcept = default;
virtual ~Mover ( void ) noexcept;
virtual void Update ( float parDelta );
PlaceableTicketType RegisterPlaceable ( Placeable* parPlaceable, PlaceableTicketType parParent=ObserversManager<Placeable*>::Ticket_Null );

View file

@ -73,6 +73,7 @@ namespace cloonel {
TicketType Add ( T parObserver, TicketType parParent=Ticket_Null );
void Remove ( TicketType parTicket ) noexcept;
void RemoveAll ( void ) noexcept;
void Update ( TicketType parTicket, T parObserver );
std::size_t size ( void ) const { return m_tree.size(); }
iterator begin ( void ) { return iterator(m_tree.begin(), &TicketedWrapperToItm); }
@ -132,6 +133,19 @@ namespace cloonel {
--m_nextTicket;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T>
void ObserversManager<T>::RemoveAll() noexcept {
if (not m_tree.empty()) {
for (typename TreeType::sibling_iterator it(m_tree.begin()), itEND(m_tree.end()); it != itEND; ++it) {
const TicketType ticket = it->ticket;
this->Remove(ticket);
}
assert(m_tree.empty());
}
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T>