diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index b7e9abee..9096a4b7 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -1865,34 +1865,49 @@ void MapWidgetImpl::RadarProductManagerDisconnect() void MapWidgetImpl::InitializeNewRadarProductView( const std::string& colorPalette) { - boost::asio::post(threadPool_, - [=, this]() - { - try - { - auto radarProductView = - context_->radar_product_view(); + boost::asio::post( + threadPool_, + [colorPalette, this]() + { + try + { + auto radarProductView = context_->radar_product_view(); - std::string colorTableFile = - settings::PaletteSettings::Instance() - .palette(colorPalette) - .GetValue(); - if (!colorTableFile.empty()) - { - std::unique_ptr colorTableStream = - util::OpenFile(colorTableFile); - std::shared_ptr colorTable = - common::ColorTable::Load(*colorTableStream); - radarProductView->LoadColorTable(colorTable); - } + auto& paletteSetting = + settings::PaletteSettings::Instance().palette(colorPalette); - radarProductView->Initialize(); - } - catch (const std::exception& ex) - { - logger_->error(ex.what()); - } - }); + std::string colorTableFile = paletteSetting.GetValue(); + if (colorTableFile.empty()) + { + colorTableFile = paletteSetting.GetDefault(); + } + + std::unique_ptr colorTableStream = + util::OpenFile(colorTableFile); + if (colorTableStream->fail()) + { + logger_->warn("Could not open color table {}", colorTableFile); + colorTableStream = util::OpenFile(paletteSetting.GetDefault()); + } + + std::shared_ptr 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(); + } + catch (const std::exception& ex) + { + logger_->error(ex.what()); + } + }); if (map_ != nullptr) {