From: Mikko Rasa Date: Wed, 29 May 2013 20:33:52 +0000 (+0300) Subject: Don't fail when adding multiple tracks to an initially empty Route X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1fc9750d1886c0a7822965700e6501090f92f4cc;p=r2c2.git Don't fail when adding multiple tracks to an initially empty Route --- diff --git a/source/libr2c2/route.cpp b/source/libr2c2/route.cpp index 788b235..38ea9f6 100644 --- a/source/libr2c2/route.cpp +++ b/source/libr2c2/route.cpp @@ -272,14 +272,21 @@ void Route::add_tracks(const set &trks) if(!tracks.count(*i)) pending.insert(*i); + if(tracks.empty()) + { + set::iterator i = pending.begin(); + tracks.insert(*i); + pending.erase(i); + } + while(!pending.empty()) { RouteValidityMask valid = ROUTE_INVALID; - for(set::const_iterator i=pending.begin(); i!=pending.end(); ++i) - if(tracks.empty() || (valid=check_validity(**i))==ROUTE_VALID) + for(set::iterator i=pending.begin(); i!=pending.end(); ++i) + if((valid=check_validity(**i))==ROUTE_VALID) { tracks.insert(*i); - pending.erase(*i); + pending.erase(i); break; }