OnlineAbsentCountriesFetcher null pointer bugfix.

This commit is contained in:
Lev Dragunov 2015-07-09 17:12:21 +03:00 committed by Alex Zolotarev
parent 575d959c2b
commit 696d32fbd6
2 changed files with 14 additions and 1 deletions

View file

@ -30,7 +30,7 @@ void OnlineAbsentCountriesFetcher::GenerateRequest(const m2::PointD & startPoint
void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries)
{
// Check whether a request was scheduled to be run on the thread.
if (!m_fetcherThread->GetRoutine())
if (!m_fetcherThread)
return;
m_fetcherThread->Join();
for (auto const & point : m_fetcherThread->GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints())
@ -43,5 +43,6 @@ void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries
LOG(LINFO, ("Online absent countries fetcher recomends to download: ", name));
countries.emplace_back(move(name));
}
m_fetcherThread.reset();
}
} // namespace routing

View file

@ -1,10 +1,12 @@
#include "testing/testing.hpp"
#include "routing/online_absent_fetcher.hpp"
#include "routing/online_cross_fetcher.hpp"
#include "geometry/point2d.hpp"
#include "std/algorithm.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
using namespace routing;
@ -46,4 +48,14 @@ UNIT_TEST(GarbadgeInputToResponseParser)
("Malformed response should not be processed."));
TEST_EQUAL(outPoints.size(), 0, ("Found mwm points in invalid request"));
}
UNIT_TEST(OnlineAbsentFetcherSingleMwmTest)
{
OnlineAbsentCountriesFetcher fetcher([](m2::PointD const & p){return "A";}, [](string const &){return nullptr;});
fetcher.GenerateRequest({1, 1}, {2, 2});
vector<string> countries;
fetcher.GetAbsentCountries(countries);
TEST(countries.empty(), ());
}
}