Fix more warnings and simplify a tiny bit.

This commit is contained in:
Richard Kimberly Heck 2020-05-19 18:06:20 -04:00
parent 6942dc9fb4
commit a2b21e3cd4
3 changed files with 15 additions and 8 deletions

View File

@ -375,8 +375,8 @@ PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b)
{
font_scaling_factor_ = int(buffer_.fontScalingFactor());
if (theApp()) {
fg_color_ = strtol(theApp()->hexName(foregroundColor()).c_str(), nullptr, 16);
bg_color_ = strtol(theApp()->hexName(backgroundColor()).c_str(), nullptr, 16);
fg_color_ = convert(theApp()->hexName(foregroundColor()).c_str(), 16);
bg_color_ = convert(theApp()->hexName(backgroundColor()).c_str(), 16);
} else {
fg_color_ = 0x0;
bg_color_ = 0xffffff;
@ -439,8 +439,8 @@ PreviewLoader::Impl::preview(string const & latex_snippet) const
int fg = 0x0;
int bg = 0xffffff;
if (theApp()) {
fg = strtol(theApp()->hexName(foregroundColor()).c_str(), nullptr, 16);
bg = strtol(theApp()->hexName(backgroundColor()).c_str(), nullptr, 16);
fg = convert(theApp()->hexName(foregroundColor()).c_str(), 16);
bg = convert(theApp()->hexName(backgroundColor()).c_str(), 16);
}
if (font_scaling_factor_ != fs || fg_color_ != fg || bg_color_ != bg) {
// Schedule refresh of all previews on zoom or color changes.

View File

@ -179,21 +179,27 @@ docstring convert<docstring>(double d)
template<>
int convert<int>(string const s)
{
return strtol(s.c_str(), nullptr, 10);
return int(strtol(s.c_str(), nullptr, 10));
}
int convert(std::string const & s, int base)
{
return int(strtol(s.c_str(), nullptr, base));
}
template<>
int convert<int>(docstring const s)
{
return strtol(to_ascii(s).c_str(), nullptr, 10);
return int(strtol(to_ascii(s).c_str(), nullptr, 10));
}
template<>
unsigned int convert<unsigned int>(string const s)
{
return strtoul(s.c_str(), nullptr, 10);
return static_cast<unsigned int>(strtoul(s.c_str(), nullptr, 10));
}
@ -214,7 +220,7 @@ double convert<double>(string const s)
template<>
int convert<int>(char const * cptr)
{
return strtol(cptr, nullptr, 10);
return int(strtol(cptr, nullptr, 10));
}

View File

@ -53,6 +53,7 @@ template<> double convert<double>(std::string const & s);
template<> int convert<int>(char const * cptr);
template<> double convert<double>(char const * cptr);
int convert(std::string const & s, int base);
} // namespace lyx
#endif