From a575fe24000b014a13ec1a72faca59c045d4fcc8 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 14 May 2019 17:50:37 +0300 Subject: [PATCH] Clearing handles after route building. --- routing/index_router.cpp | 10 ++++++++++ routing/index_router.hpp | 1 + routing/pedestrian_directions.hpp | 1 + 3 files changed, 12 insertions(+) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index e9130049f2..a0ad8573c2 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -302,6 +302,12 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d dummy /* best segment is almost codirectional */); } +void IndexRouter::ClearState() +{ + m_roadGraph.ClearState(); + m_directionsEngine->Clear(); +} + RouterResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints, m2::PointD const & startDirection, bool adjustToPrevRoute, @@ -323,6 +329,10 @@ RouterResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints, try { + SCOPE_GUARD(featureRoadGraphClear, [this]{ + this->ClearState(); + }); + if (adjustToPrevRoute && m_lastRoute && m_lastFakeEdges && finalPoint == m_lastRoute->GetFinish()) { diff --git a/routing/index_router.hpp b/routing/index_router.hpp index d071054ba6..275b52a65a 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -78,6 +78,7 @@ public: // IRouter overrides: std::string GetName() const override { return m_name; } + void ClearState() override; RouterResultCode CalculateRoute(Checkpoints const & checkpoints, m2::PointD const & startDirection, bool adjustToPrevRoute, RouterDelegate const & delegate, Route & route) override; diff --git a/routing/pedestrian_directions.hpp b/routing/pedestrian_directions.hpp index ec889cc082..0e5f9f98bb 100644 --- a/routing/pedestrian_directions.hpp +++ b/routing/pedestrian_directions.hpp @@ -19,6 +19,7 @@ public: base::Cancellable const & cancellable, Route::TTurns & turns, Route::TStreets & streetNames, vector & routeGeometry, vector & segments) override; + void Clear() override {} private: void CalculateTurns(IndexRoadGraph const & graph, std::vector const & routeEdges,