From 1005fa0c91fa79622e264f10a31ff266d036dc72 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 24 Sep 2017 03:02:27 +0200 Subject: [PATCH] Implement rest of zone insertion code. --- server/TracyView.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 1f915a98..0196e494 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -387,7 +387,31 @@ void View::InsertZone( Event* zone, Event* parent, Vector& vec ) } else { + zone->parent = parent; + // here be dragons + // this code is not tested, as it's a fallback for edge cases, which haven't happened + if( zone->end == -1 ) + { + for( auto zit = it; zit != vec.end(); ++zit ) + { + (*zit)->parent = zone; + zone->child.push_back( zone ); + } + vec.erase( it, vec.end() ); + vec.push_back( zone ); + } + else + { + auto eit = std::lower_bound( it, vec.end(), zone->end, [] ( const auto& l, const auto& r ) { return l->start < r; } ); + for( auto zit = it; zit != eit; zit++ ) + { + (*zit)->parent = zone; + zone->child.push_back( zone ); + } + auto nit = vec.erase( it, eit ); + vec.insert( nit, zone ); + } } } }