Fix the assert when quitting.
This commit is contained in:
parent
0bdaa63db1
commit
1037e2e141
3 changed files with 21 additions and 1 deletions
|
@ -22,6 +22,12 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace cloonel {
|
namespace cloonel {
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
Mover::~Mover() noexcept {
|
||||||
|
m_placeables.RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
void Mover::Update (float parDelta) {
|
void Mover::Update (float parDelta) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace cloonel {
|
||||||
};
|
};
|
||||||
|
|
||||||
Mover ( void ) = default;
|
Mover ( void ) = default;
|
||||||
virtual ~Mover ( void ) noexcept = default;
|
virtual ~Mover ( void ) noexcept;
|
||||||
|
|
||||||
virtual void Update ( float parDelta );
|
virtual void Update ( float parDelta );
|
||||||
PlaceableTicketType RegisterPlaceable ( Placeable* parPlaceable, PlaceableTicketType parParent=ObserversManager<Placeable*>::Ticket_Null );
|
PlaceableTicketType RegisterPlaceable ( Placeable* parPlaceable, PlaceableTicketType parParent=ObserversManager<Placeable*>::Ticket_Null );
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace cloonel {
|
||||||
|
|
||||||
TicketType Add ( T parObserver, TicketType parParent=Ticket_Null );
|
TicketType Add ( T parObserver, TicketType parParent=Ticket_Null );
|
||||||
void Remove ( TicketType parTicket ) noexcept;
|
void Remove ( TicketType parTicket ) noexcept;
|
||||||
|
void RemoveAll ( void ) noexcept;
|
||||||
void Update ( TicketType parTicket, T parObserver );
|
void Update ( TicketType parTicket, T parObserver );
|
||||||
std::size_t size ( void ) const { return m_tree.size(); }
|
std::size_t size ( void ) const { return m_tree.size(); }
|
||||||
iterator begin ( void ) { return iterator(m_tree.begin(), &TicketedWrapperToItm); }
|
iterator begin ( void ) { return iterator(m_tree.begin(), &TicketedWrapperToItm); }
|
||||||
|
@ -132,6 +133,19 @@ namespace cloonel {
|
||||||
--m_nextTicket;
|
--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>
|
template <typename T>
|
||||||
|
|
Loading…
Reference in a new issue