Permalink
Browse files

Use the result of erase() when removing iterators from containers.

  • Loading branch information...
Julien Jorge
Julien Jorge committed Oct 8, 2013
1 parent a1df4e1 commit 21b3934f5e59417d9e3e5f51805f3bfd70e8c53e
@@ -1144,11 +1144,7 @@ void bear::engine::base_item::clean_life_chain()
while ( it != m_life_chain.end() )
if ( *it == (universe::physical_item*)NULL )
{
life_chain_list::iterator tmp(it);
++it;
m_life_chain.erase( tmp );
}
it = m_life_chain.erase( it );
else
++it;
} // base_item::clean_life_chain()
@@ -55,11 +55,7 @@ void bear::engine::balloon_layer::progress( universe::time_type elapsed_time )
for ( it = m_speakers.begin(); it != m_speakers.end(); )
if ( (*it) == (speaker_item*)(NULL) )
{
speaker_list::iterator it2 = it;
++it;
m_speakers.erase(it2);
}
it = m_speakers.erase(it);
else
{
placement.add_speaker( **it, get_bounding_box_on_screen(*it) );
@@ -474,14 +474,10 @@ void bear::engine::item_with_toggle<Base>::toggle_linked
( base_item* activator )
{
handle_list::iterator it;
std::list<handle_list::iterator> dead;
for (it=m_linked.begin(); it!=m_linked.end(); ++it)
if ( *it == (with_toggle*)NULL )
dead.push_back(it);
it = m_linked.erase(it);
else
(*it)->toggle( m_is_on, activator );
for ( ; !dead.empty(); dead.pop_front() )
m_linked.erase(dead.front());
} // item_with_toggle::toggle_linked()
@@ -167,11 +167,7 @@ void bear::line::adjust_position_and_size()
for ( point_list_type::iterator it=m_points.begin(); it!=m_points.end(); )
if ( *it == NULL )
{
point_list_type::iterator tmp(it);
++it;
m_points.erase(tmp);
}
it = m_points.erase(it);
else
{
left = std::min(left, (*it)->get_left());
@@ -94,11 +94,7 @@ void bear::path_tracer::progress( universe::time_type elapsed_time )
while ( it != m_traces.end() )
if ( *it == (universe::physical_item*)NULL )
{
handle_list_type::iterator tmp(it);
++it;
m_traces.erase(tmp);
}
it = m_traces.erase(it);
else
++it;
} // path_tracer::progress()
@@ -239,11 +239,7 @@ void bear::rolling_credits::progress( universe::time_type elapsed_time )
it->turn_on();
if ( p.y + it->get_size().y > get_top() )
{
std::list<credit_line>::iterator tmp=it;
++it;
m_lines.erase(tmp);
}
it = m_lines.erase(it);
else
++it;

0 comments on commit 21b3934

Please sign in to comment.