mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 12:50:06 +00:00
Fall back to default color palette on failure to load color palette.
This commit is contained in:
parent
b4f888ad15
commit
8be9cc72de
1 changed files with 32 additions and 10 deletions
|
|
@ -1866,26 +1866,48 @@ void MapWidgetImpl::InitializeNewRadarProductView(
|
||||||
const std::string& colorPalette)
|
const std::string& colorPalette)
|
||||||
{
|
{
|
||||||
boost::asio::post(threadPool_,
|
boost::asio::post(threadPool_,
|
||||||
[=, this]()
|
[colorPalette, this]()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto radarProductView =
|
auto radarProductView =
|
||||||
context_->radar_product_view();
|
context_->radar_product_view();
|
||||||
|
|
||||||
|
auto& paletteSetting =
|
||||||
|
settings::PaletteSettings::Instance().palette(
|
||||||
|
colorPalette);
|
||||||
|
|
||||||
std::string colorTableFile =
|
std::string colorTableFile =
|
||||||
settings::PaletteSettings::Instance()
|
paletteSetting.GetValue();
|
||||||
.palette(colorPalette)
|
if (colorTableFile.empty())
|
||||||
.GetValue();
|
|
||||||
if (!colorTableFile.empty())
|
|
||||||
{
|
{
|
||||||
std::unique_ptr<std::istream> colorTableStream =
|
colorTableFile = paletteSetting.GetDefault();
|
||||||
util::OpenFile(colorTableFile);
|
|
||||||
std::shared_ptr<common::ColorTable> colorTable =
|
|
||||||
common::ColorTable::Load(*colorTableStream);
|
|
||||||
radarProductView->LoadColorTable(colorTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<std::istream> colorTableStream =
|
||||||
|
util::OpenFile(colorTableFile);
|
||||||
|
if (colorTableStream->fail())
|
||||||
|
{
|
||||||
|
logger_->warn("Could not open color table {}",
|
||||||
|
colorTableFile);
|
||||||
|
colorTableStream =
|
||||||
|
util::OpenFile(paletteSetting.GetDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<common::ColorTable> colorTable =
|
||||||
|
common::ColorTable::Load(*colorTableStream);
|
||||||
|
if (!colorTable->IsValid())
|
||||||
|
{
|
||||||
|
logger_->warn("Could not load color table {}",
|
||||||
|
colorTableFile);
|
||||||
|
colorTableStream =
|
||||||
|
util::OpenFile(paletteSetting.GetDefault());
|
||||||
|
colorTable =
|
||||||
|
common::ColorTable::Load(*colorTableStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
radarProductView->LoadColorTable(colorTable);
|
||||||
|
|
||||||
radarProductView->Initialize();
|
radarProductView->Initialize();
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex)
|
catch (const std::exception& ex)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue