From 4dc5610cd4ae529321adf19ffb97762f62a4d563 Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Thu, 10 Mar 2016 15:04:24 +0300 Subject: [PATCH] [new downloader] Fix problem with hiding download dialog on high scales --- map/framework.cpp | 52 +++++++++++++++++++++++------------------------ map/framework.hpp | 1 - 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index a14250a287..61b2d9f3f0 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -943,34 +943,34 @@ void Framework::ClearAllCaches() m_searchEngine->ClearCaches(); } -void Framework::OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel) -{ - if (zoomLevel <= scales::GetUpperWorldScale()) - m_deferredCountryUpdate.Drop(); - else - m_deferredCountryUpdate.RestartWith([this, pt, zoomLevel] - { - OnUpdateCurrentCountry(pt, zoomLevel); - }); -} - void Framework::OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel) { - if (zoomLevel <= scales::GetUpperWorldScale()) - return; - - storage::TCountryId newCountryId = m_infoGetter->GetRegionCountryId(m2::PointD(pt)); - - if (newCountryId == m_lastReportedCountry) - return; - - m_lastReportedCountry = newCountryId; - - GetPlatform().RunOnGuiThread([this, newCountryId]() + auto action = [this](TCountryId const &countryId) { - if (m_currentCountryChanged != nullptr) - m_currentCountryChanged(newCountryId); - }); + if (countryId == m_lastReportedCountry) + return; + m_lastReportedCountry = countryId; + auto guiCallback = [this, countryId] + { + if (m_currentCountryChanged != nullptr) + m_currentCountryChanged(countryId); + }; + GetPlatform().RunOnGuiThread(guiCallback); + }; + + if (zoomLevel <= scales::GetUpperWorldScale()) + { + m_deferredCountryUpdate.Drop(); + action(kInvalidCountryId); + } + else + { + m_deferredCountryUpdate.RestartWith([this, pt, action] + { + storage::TCountryId newCountryId = m_infoGetter->GetRegionCountryId(m2::PointD(pt)); + action(newCountryId); + }); + } } void Framework::SetCurrentCountryChangedListener(TCurrentCountryChanged const & listener) @@ -1364,7 +1364,7 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, auto isCountryLoadedFn = bind(&Framework::IsCountryLoaded, this, _1); auto isCountryLoadedByNameFn = bind(&Framework::IsCountryLoadedByName, this, _1); - auto updateCurrentCountryFn = bind(&Framework::OnCheckUpdateCurrentCountry, this, _1, _2); + auto updateCurrentCountryFn = bind(&Framework::OnUpdateCurrentCountry, this, _1, _2); bool allow3d; bool allow3dBuildings; diff --git a/map/framework.hpp b/map/framework.hpp index 1c25cd9679..e7f97a70c2 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -359,7 +359,6 @@ private: void FillSearchResultsMarks(search::Results const & results); - void OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel); void OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel); storage::TCountryId m_lastReportedCountry;