forked from organicmaps/organicmaps
return empty string in case when empty rating
This commit is contained in:
parent
0d5a084579
commit
906a24775f
2 changed files with 6 additions and 6 deletions
|
@ -10,7 +10,6 @@ namespace place_page
|
|||
char const * const Info::kSubtitleSeparator = " • ";
|
||||
char const * const Info::kStarSymbol = "★";
|
||||
char const * const Info::kMountainSymbol = "▲";
|
||||
char const * const Info::kEmptyRatingSymbol = "-";
|
||||
char const * const Info::kPricingSymbol = "$";
|
||||
|
||||
bool Info::IsFeature() const { return m_featureID.IsValid(); }
|
||||
|
@ -123,9 +122,11 @@ string Info::GetRatingFormatted() const
|
|||
if (!IsSponsored())
|
||||
return string();
|
||||
|
||||
auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING);
|
||||
char const * rating = r.empty() ? kEmptyRatingSymbol : r.c_str();
|
||||
int const size = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating);
|
||||
auto const rating = GetMetadata().Get(feature::Metadata::FMD_RATING);
|
||||
if (rating.empty())
|
||||
return rating;
|
||||
|
||||
int const size = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating.c_str());
|
||||
if (size < 0)
|
||||
{
|
||||
LOG(LERROR, ("Incorrect size for string:", m_localizedRatingString, ", rating:", rating));
|
||||
|
@ -133,7 +134,7 @@ string Info::GetRatingFormatted() const
|
|||
}
|
||||
|
||||
vector<char> buf(size + 1);
|
||||
snprintf(buf.data(), buf.size(), m_localizedRatingString.c_str(), rating);
|
||||
snprintf(buf.data(), buf.size(), m_localizedRatingString.c_str(), rating.c_str());
|
||||
return string(buf.begin(), buf.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ public:
|
|||
static char const * const kSubtitleSeparator;
|
||||
static char const * const kStarSymbol;
|
||||
static char const * const kMountainSymbol;
|
||||
static char const * const kEmptyRatingSymbol;
|
||||
static char const * const kPricingSymbol;
|
||||
|
||||
bool IsFeature() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue