forked from organicmaps/organicmaps
Protecting callback which called from UI thread.
This commit is contained in:
parent
9603b05a08
commit
42ca9da221
2 changed files with 6 additions and 4 deletions
|
@ -40,7 +40,7 @@ void RoutingSession::RebuildRoute(m2::PointD const & startPoint, TReadyCallbackF
|
|||
|
||||
// Use old-style callback constraction, because lambda constructs buggy function on Android
|
||||
// (callback param isn't captured by value).
|
||||
m_router->CalculateRoute(startPoint, DoReadyCallback(*this, callback), startPoint - m_lastGoodPosition);
|
||||
m_router->CalculateRoute(startPoint, DoReadyCallback(*this, callback, m_routeSessionMutex), startPoint - m_lastGoodPosition);
|
||||
}
|
||||
|
||||
void RoutingSession::DoReadyCallback::operator() (Route & route, IRouter::ResultCode e)
|
||||
|
@ -50,6 +50,8 @@ void RoutingSession::DoReadyCallback::operator() (Route & route, IRouter::Result
|
|||
else
|
||||
m_rs.m_state = RouteNotReady;
|
||||
|
||||
threads::MutexGuard guard(m_routeSessionMutexInner);
|
||||
UNUSED_VALUE(guard);
|
||||
m_callback(m_rs.m_route, e);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,15 +66,15 @@ private:
|
|||
{
|
||||
RoutingSession & m_rs;
|
||||
TReadyCallbackFn m_callback;
|
||||
threads::Mutex & m_routeSessionMutexInner;
|
||||
|
||||
DoReadyCallback(RoutingSession & rs, TReadyCallbackFn const & cb)
|
||||
: m_rs(rs), m_callback(cb)
|
||||
DoReadyCallback(RoutingSession & rs, TReadyCallbackFn const & cb, threads::Mutex & routeSessionMutex)
|
||||
: m_rs(rs), m_callback(cb), m_routeSessionMutexInner(routeSessionMutex)
|
||||
{
|
||||
}
|
||||
|
||||
void operator() (Route & route, IRouter::ResultCode e);
|
||||
};
|
||||
|
||||
void AssignRoute(Route & route);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue