forked from organicmaps/organicmaps-tmp
Fixed crash on transit marks creating.
This commit is contained in:
parent
2b22933b72
commit
58ca895349
3 changed files with 26 additions and 21 deletions
|
@ -447,16 +447,16 @@ void RoutingManager::InsertRoute(Route const & route)
|
|||
// TODO: Now we always update whole route, so we need to remove previous one.
|
||||
RemoveRoute(false /* deactivateFollowing */);
|
||||
|
||||
std::unique_ptr<TransitRouteDisplay> transitRouteDisplay;
|
||||
std::shared_ptr<TransitRouteDisplay> transitRouteDisplay;
|
||||
auto numMwmIds = make_shared<NumMwmIds>();
|
||||
if (m_currentRouterType == RouterType::Transit)
|
||||
{
|
||||
m_delegate.RegisterCountryFilesOnRoute(numMwmIds);
|
||||
auto getMwmId = [this, &numMwmIds](routing::NumMwmId numMwmId)
|
||||
auto getMwmId = [this, numMwmIds](routing::NumMwmId numMwmId)
|
||||
{
|
||||
return m_callbacks.m_indexGetter().GetMwmIdByCountryFile(numMwmIds->GetFile(numMwmId));
|
||||
};
|
||||
transitRouteDisplay = make_unique<TransitRouteDisplay>(m_transitReadManager, getMwmId,
|
||||
transitRouteDisplay = make_shared<TransitRouteDisplay>(m_transitReadManager, getMwmId,
|
||||
m_callbacks.m_stringsBundleGetter,
|
||||
m_bmManager, m_transitSymbolSizes);
|
||||
}
|
||||
|
@ -547,9 +547,19 @@ void RoutingManager::InsertRoute(Route const & route)
|
|||
m_drapeSubroutes.push_back(subrouteId);
|
||||
}
|
||||
|
||||
lock_guard<mutex> lock(m_drapeSubroutesMutex);
|
||||
m_transitRouteInfo = m_currentRouterType == RouterType::Transit ? transitRouteDisplay->GetRouteInfo()
|
||||
: TransitRouteInfo();
|
||||
{
|
||||
lock_guard<mutex> lock(m_drapeSubroutesMutex);
|
||||
m_transitRouteInfo = m_currentRouterType == RouterType::Transit ? transitRouteDisplay->GetRouteInfo()
|
||||
: TransitRouteInfo();
|
||||
}
|
||||
|
||||
if (m_currentRouterType == RouterType::Transit)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [transitRouteDisplay = std::move(transitRouteDisplay)]()
|
||||
{
|
||||
transitRouteDisplay->CreateTransitMarks();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::FollowRoute()
|
||||
|
|
|
@ -201,8 +201,6 @@ void TransitRouteDisplay::ProcessSubroute(vector<RouteSegment> const & segments,
|
|||
if (!m_transitReadManager.GetTransitDisplayInfo(transitDisplayInfos))
|
||||
return;
|
||||
|
||||
std::vector<TransitMarkInfo> transitMarks;
|
||||
|
||||
subroute.m_maxPixelWidth = m_maxSubrouteWidth;
|
||||
subroute.m_styleType = df::SubrouteStyleType::Multiple;
|
||||
subroute.m_style.clear();
|
||||
|
@ -327,7 +325,7 @@ void TransitRouteDisplay::ProcessSubroute(vector<RouteSegment> const & segments,
|
|||
subroute.m_markers.push_back(marker);
|
||||
marker = df::SubrouteMarker();
|
||||
|
||||
transitMarks.push_back(transitMarkInfo);
|
||||
m_transitMarks.push_back(transitMarkInfo);
|
||||
transitMarkInfo = TransitMarkInfo();
|
||||
|
||||
lastDir = currentDir;
|
||||
|
@ -371,7 +369,7 @@ void TransitRouteDisplay::ProcessSubroute(vector<RouteSegment> const & segments,
|
|||
transitMarkInfo.m_type = TransitMarkInfo::Type::KeyStop;
|
||||
transitMarkInfo.m_symbolName = kTransitSymbols.at(transitType);
|
||||
transitMarkInfo.m_color = lastColor;
|
||||
transitMarks.push_back(transitMarkInfo);
|
||||
m_transitMarks.push_back(transitMarkInfo);
|
||||
transitMarkInfo = TransitMarkInfo();
|
||||
}
|
||||
else
|
||||
|
@ -400,17 +398,12 @@ void TransitRouteDisplay::ProcessSubroute(vector<RouteSegment> const & segments,
|
|||
gateMarkInfo.m_titles.push_back(TransitTitle(title, df::GetTransitTextColorName("default")));
|
||||
}
|
||||
|
||||
transitMarks.push_back(gateMarkInfo);
|
||||
m_transitMarks.push_back(gateMarkInfo);
|
||||
}
|
||||
}
|
||||
|
||||
m_routeInfo.m_totalDistInMeters = prevDistance;
|
||||
m_routeInfo.m_totalTimeInSec = static_cast<int>(ceil(prevTime));
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, transitMarks]()
|
||||
{
|
||||
CreateTransitMarks(transitMarks);
|
||||
});
|
||||
}
|
||||
|
||||
void TransitRouteDisplay::CollectTransitDisplayInfo(vector<RouteSegment> const & segments,
|
||||
|
@ -475,8 +468,11 @@ TransitMark * TransitRouteDisplay::CreateMark(m2::PointD const & pt, FeatureID c
|
|||
return transitMark;
|
||||
}
|
||||
|
||||
void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const & transitMarks)
|
||||
void TransitRouteDisplay::CreateTransitMarks()
|
||||
{
|
||||
if (m_transitMarks.empty())
|
||||
return;
|
||||
|
||||
std::vector<m2::PointF> const transferMarkerSizes = GetTransitMarkerSizes(kTransferMarkerScale, m_maxSubrouteWidth);
|
||||
std::vector<m2::PointF> const stopMarkerSizes = GetTransitMarkerSizes(kStopMarkerScale, m_maxSubrouteWidth);
|
||||
|
||||
|
@ -487,9 +483,8 @@ void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const
|
|||
auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
|
||||
|
||||
auto editSession = m_bmManager->GetEditSession();
|
||||
for (size_t i = 0; i < transitMarks.size(); ++i)
|
||||
for (auto const & mark : m_transitMarks)
|
||||
{
|
||||
auto const & mark = transitMarks[i];
|
||||
auto transitMark = CreateMark(mark.m_point, mark.m_featureId);
|
||||
|
||||
dp::TitleDecl titleDecl;
|
||||
|
|
|
@ -108,14 +108,13 @@ public:
|
|||
std::map<std::string, m2::PointF> const & transitSymbolSizes);
|
||||
|
||||
void ProcessSubroute(std::vector<routing::RouteSegment> const & segments, df::Subroute & subroute);
|
||||
|
||||
void CreateTransitMarks();
|
||||
|
||||
TransitRouteInfo const & GetRouteInfo();
|
||||
|
||||
private:
|
||||
void CollectTransitDisplayInfo(std::vector<routing::RouteSegment> const & segments,
|
||||
TransitDisplayInfos & transitDisplayInfos);
|
||||
void CreateTransitMarks(std::vector<TransitMarkInfo> const & transitMarks);
|
||||
TransitMark * CreateMark(m2::PointD const & pt, FeatureID const & fid);
|
||||
|
||||
TransitReadManager & m_transitReadManager;
|
||||
|
@ -125,6 +124,7 @@ private:
|
|||
std::map<std::string, m2::PointF> const & m_symbolSizes;
|
||||
|
||||
TransitRouteInfo m_routeInfo;
|
||||
std::vector<TransitMarkInfo> m_transitMarks;
|
||||
|
||||
int m_subrouteIndex = 0;
|
||||
float m_maxSubrouteWidth = -1.0f;
|
||||
|
|
Loading…
Add table
Reference in a new issue