forked from organicmaps/organicmaps
Fixed updating country info with invalid map id
This commit is contained in:
parent
c3229b8fc0
commit
e0b57d213e
6 changed files with 25 additions and 4 deletions
|
@ -167,10 +167,10 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<CountryInfoUpdateMessage> msg = message;
|
||||
gui::CountryStatusHelper & helper = gui::DrapeGui::Instance().GetCountryStatusHelper();
|
||||
if (msg->IsCountryLoaded())
|
||||
if (!msg->IsValid() || msg->IsCountryLoaded())
|
||||
{
|
||||
// country has already loaded, so we do not show country status gui
|
||||
// even is the case then this country is updating
|
||||
// Country has already loaded, so we do not show country status gui
|
||||
// even is the case then this country is updating.
|
||||
helper.Clear();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -233,6 +233,13 @@ void DrapeEngine::SetCountryInfo(gui::CountryInfo const & info, bool isCurrentCo
|
|||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetInvalidCountryInfo()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<CountryInfoUpdateMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetCompassInfo(location::CompassInfo const & info)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
void UpdateMapStyle();
|
||||
|
||||
void SetCountryInfo(gui::CountryInfo const & info, bool isCurrentCountry, bool isCountryLoaded);
|
||||
void SetInvalidCountryInfo();
|
||||
void SetCompassInfo(location::CompassInfo const & info);
|
||||
void SetGpsInfo(location::GpsInfo const & info, bool isNavigable, location::RouteMatchingInfo const & routeInfo);
|
||||
void MyPositionNextMode();
|
||||
|
|
|
@ -304,22 +304,29 @@ private:
|
|||
class CountryInfoUpdateMessage : public Message
|
||||
{
|
||||
public:
|
||||
CountryInfoUpdateMessage()
|
||||
: m_isValid(false)
|
||||
{}
|
||||
|
||||
CountryInfoUpdateMessage(gui::CountryInfo const & info, bool isCurrentCountry,
|
||||
bool isCountryLoaded)
|
||||
: m_countryInfo(info)
|
||||
, m_isCurrentCountry(isCurrentCountry)
|
||||
, m_isCountryLoaded(isCountryLoaded)
|
||||
, m_isValid(true)
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::CountryInfoUpdate;}
|
||||
gui::CountryInfo const & GetCountryInfo() const { return m_countryInfo; }
|
||||
bool IsCurrentCountry() const { return m_isCurrentCountry; }
|
||||
bool IsCountryLoaded() const { return m_isCountryLoaded; }
|
||||
bool IsValid() const { return m_isValid; }
|
||||
|
||||
private:
|
||||
gui::CountryInfo m_countryInfo;
|
||||
bool m_isCurrentCountry;
|
||||
bool m_isCountryLoaded;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
class CountryStatusRecacheMessage : public Message
|
||||
|
|
|
@ -70,7 +70,7 @@ string const & VisualParams::GetResourcePostfix(double visualScale, bool isYotaD
|
|||
|
||||
// Looking for the nearest available scale.
|
||||
int postfixIndex = -1;
|
||||
double minValue = numeric_limits<float>::max();
|
||||
double minValue = numeric_limits<double>::max();
|
||||
for (int i = 0; i < ARRAY_SIZE(postfixes); i++)
|
||||
{
|
||||
double val = fabs(postfixes[i].second - visualScale);
|
||||
|
|
|
@ -842,6 +842,12 @@ void Framework::OnDownloadRetryCallback(storage::TIndex const & countryIndex)
|
|||
void Framework::OnUpdateCountryIndex(storage::TIndex const & currentIndex, m2::PointF const & pt)
|
||||
{
|
||||
storage::TIndex newCountryIndex = GetCountryIndex(m2::PointD(pt));
|
||||
if (!newCountryIndex.IsValid())
|
||||
{
|
||||
m_drapeEngine->SetInvalidCountryInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentIndex != newCountryIndex)
|
||||
UpdateCountryInfo(newCountryIndex, true /* isCurrentCountry */);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue