RoutingManager race codition fix which leads to leaving a route on the map.

This commit is contained in:
Vladimir Byko-Ianko 2018-10-10 09:44:23 +03:00 committed by Daria Volvenkova
parent d2a45f8d28
commit 4f46fcd585
2 changed files with 4 additions and 12 deletions

View file

@ -438,11 +438,11 @@ void RoutingManager::RemoveRoute(bool deactivateFollowing)
}
else
{
auto const subroutes = GetSubrouteIds();
df::DrapeEngineLockGuard lock(m_drapeEngine);
if (lock)
{
for (auto const & subrouteId : subroutes)
lock_guard<mutex> l(m_drapeSubroutesMutex);
for (auto const & subrouteId : m_drapeSubroutes)
lock.Get()->RemoveSubroute(subrouteId, false /* deactivateFollowing */);
}
}
@ -1339,20 +1339,13 @@ TransitRouteInfo RoutingManager::GetTransitRouteInfo() const
return m_transitRouteInfo;
}
vector<dp::DrapeID> RoutingManager::GetSubrouteIds() const
{
lock_guard<mutex> lock(m_drapeSubroutesMutex);
return m_drapeSubroutes;
}
void RoutingManager::SetSubroutesVisibility(bool visible)
{
auto const subroutes = GetSubrouteIds();
df::DrapeEngineLockGuard lock(m_drapeEngine);
if (!lock)
return;
for (auto const & subrouteId : subroutes)
lock_guard<mutex> l(m_drapeSubroutesMutex);
for (auto const & subrouteId : m_drapeSubroutes)
lock.Get()->SetSubrouteVisibility(subrouteId, visible);
}

View file

@ -283,7 +283,6 @@ private:
m2::RectD ShowPreviewSegments(std::vector<RouteMarkData> const & routePoints);
void HidePreviewSegments();
std::vector<dp::DrapeID> GetSubrouteIds() const;
void SetSubroutesVisibility(bool visible);
void CancelRecommendation(Recommendation recommendation);