"this" must be explicit in lambda capture

This commit is contained in:
Dan Paulat 2023-04-17 18:29:37 -05:00
parent 31db9a4315
commit a3afd71f03
19 changed files with 132 additions and 129 deletions

View file

@ -269,14 +269,14 @@ void MainWindow::on_actionOpenNexrad_triggered()
dialog, dialog,
&QFileDialog::finished, &QFileDialog::finished,
this, this,
[=]() { update(); }, [this]() { update(); },
Qt::QueuedConnection); Qt::QueuedConnection);
connect( connect(
dialog, dialog,
&QFileDialog::fileSelected, &QFileDialog::fileSelected,
this, this,
[=](const QString& file) [=, this](const QString& file)
{ {
logger_->info("Selected: {}", file.toStdString()); logger_->info("Selected: {}", file.toStdString());
@ -287,7 +287,7 @@ void MainWindow::on_actionOpenNexrad_triggered()
request.get(), request.get(),
&request::NexradFileRequest::RequestComplete, &request::NexradFileRequest::RequestComplete,
this, this,
[=](std::shared_ptr<request::NexradFileRequest> request) [=, this](std::shared_ptr<request::NexradFileRequest> request)
{ {
std::shared_ptr<types::RadarProductRecord> record = std::shared_ptr<types::RadarProductRecord> record =
request->radar_product_record(); request->radar_product_record();
@ -331,13 +331,13 @@ void MainWindow::on_actionOpenTextEvent_triggered()
dialog, dialog,
&QFileDialog::finished, &QFileDialog::finished,
this, this,
[=]() { update(); }, [this]() { update(); },
Qt::QueuedConnection); Qt::QueuedConnection);
connect(dialog, connect(dialog,
&QFileDialog::fileSelected, &QFileDialog::fileSelected,
this, this,
[=](const QString& file) [this](const QString& file)
{ {
logger_->info("Selected: {}", file.toStdString()); logger_->info("Selected: {}", file.toStdString());
p->textEventManager_->LoadFile(file.toStdString()); p->textEventManager_->LoadFile(file.toStdString());
@ -483,7 +483,7 @@ void MainWindowImpl::ConfigureMapLayout()
maps_.resize(mapCount); maps_.resize(mapCount);
auto MoveSplitter = [=](int /*pos*/, int /*index*/) auto MoveSplitter = [=, this](int /*pos*/, int /*index*/)
{ {
QSplitter* s = static_cast<QSplitter*>(sender()); QSplitter* s = static_cast<QSplitter*>(sender());
@ -575,7 +575,7 @@ void MainWindowImpl::ConnectOtherSignals()
connect(qApp, connect(qApp,
&QApplication::focusChanged, &QApplication::focusChanged,
mainWindow_, mainWindow_,
[=](QWidget* /*old*/, QWidget* now) { HandleFocusChange(now); }); [this](QWidget* /*old*/, QWidget* now) { HandleFocusChange(now); });
connect(level2ProductsWidget_, connect(level2ProductsWidget_,
&ui::Level2ProductsWidget::RadarProductSelected, &ui::Level2ProductsWidget::RadarProductSelected,
mainWindow_, mainWindow_,
@ -605,7 +605,7 @@ void MainWindowImpl::ConnectOtherSignals()
alertDockWidget_, alertDockWidget_,
&ui::AlertDockWidget::MoveMap, &ui::AlertDockWidget::MoveMap,
this, this,
[=](double latitude, double longitude) [this](double latitude, double longitude)
{ {
for (map::MapWidget* map : maps_) for (map::MapWidget* map : maps_)
{ {

View file

@ -506,7 +506,7 @@ void RadarProductManager::EnableRefresh(common::RadarProductGroup group,
// Only enable refresh on available products // Only enable refresh on available products
scwx::util::async( scwx::util::async(
[=]() [=, this]()
{ {
providerManager->provider_->RequestAvailableProducts(); providerManager->provider_->RequestAvailableProducts();
auto availableProducts = auto availableProducts =
@ -597,7 +597,7 @@ void RadarProductManagerImpl::RefreshData(
} }
scwx::util::async( scwx::util::async(
[=]() [=, this]()
{ {
auto [newObjects, totalObjects] = auto [newObjects, totalObjects] =
providerManager->provider_->Refresh(); providerManager->provider_->Refresh();
@ -647,7 +647,7 @@ void RadarProductManagerImpl::RefreshData(
{ {
providerManager->refreshTimer_.expires_after(interval); providerManager->refreshTimer_.expires_after(interval);
providerManager->refreshTimer_.async_wait( providerManager->refreshTimer_.async_wait(
[=](const boost::system::error_code& e) [=, this](const boost::system::error_code& e)
{ {
if (e == boost::system::errc::success) if (e == boost::system::errc::success)
{ {
@ -1151,7 +1151,7 @@ void RadarProductManager::UpdateAvailableProducts()
logger_->debug("UpdateAvailableProducts()"); logger_->debug("UpdateAvailableProducts()");
scwx::util::async( scwx::util::async(
[=]() [this]()
{ {
auto level3ProviderManager = auto level3ProviderManager =
p->GetLevel3ProviderManager(kDefaultLevel3Product_); p->GetLevel3ProviderManager(kDefaultLevel3Product_);

View file

@ -35,7 +35,7 @@ public:
warningsProvider_ {kDefaultWarningsProviderUrl} warningsProvider_ {kDefaultWarningsProviderUrl}
{ {
util::async( util::async(
[=]() [this]()
{ {
main::Application::WaitForInitialization(); main::Application::WaitForInitialization();
logger_->debug("Start Refresh"); logger_->debug("Start Refresh");
@ -105,7 +105,7 @@ void TextEventManager::LoadFile(const std::string& filename)
logger_->debug("LoadFile: {}", filename); logger_->debug("LoadFile: {}", filename);
util::async( util::async(
[=]() [=, this]()
{ {
awips::TextProductFile file; awips::TextProductFile file;
@ -217,7 +217,7 @@ void TextEventManager::Impl::Refresh()
using namespace std::chrono; using namespace std::chrono;
refreshTimer_.expires_after(15s); refreshTimer_.expires_after(15s);
refreshTimer_.async_wait( refreshTimer_.async_wait(
[=](const boost::system::error_code& e) [this](const boost::system::error_code& e)
{ {
if (e == boost::asio::error::operation_aborted) if (e == boost::asio::error::operation_aborted)
{ {

View file

@ -332,7 +332,7 @@ void AlertLayerHandler::UpdateAlerts()
using namespace std::chrono; using namespace std::chrono;
alertUpdateTimer_.expires_after(15s); alertUpdateTimer_.expires_after(15s);
alertUpdateTimer_.async_wait( alertUpdateTimer_.async_wait(
[=](const boost::system::error_code& e) [this](const boost::system::error_code& e)
{ {
if (e == boost::asio::error::operation_aborted) if (e == boost::asio::error::operation_aborted)
{ {

View file

@ -110,7 +110,7 @@ void ColorTableLayer::Initialize()
connect(context()->radar_product_view().get(), connect(context()->radar_product_view().get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableUpdated,
this, this,
[=]() { p->colorTableNeedsUpdate_ = true; }); [this]() { p->colorTableNeedsUpdate_ = true; });
} }
void ColorTableLayer::Render( void ColorTableLayer::Render(

View file

@ -797,13 +797,13 @@ void MapWidgetImpl::RadarProductManagerConnect()
connect(radarProductManager_.get(), connect(radarProductManager_.get(),
&manager::RadarProductManager::Level3ProductsChanged, &manager::RadarProductManager::Level3ProductsChanged,
this, this,
[&]() { emit widget_->Level3ProductsChanged(); }); [this]() { emit widget_->Level3ProductsChanged(); });
connect( connect(
radarProductManager_.get(), radarProductManager_.get(),
&manager::RadarProductManager::NewDataAvailable, &manager::RadarProductManager::NewDataAvailable,
this, this,
[&](common::RadarProductGroup group, [this](common::RadarProductGroup group,
const std::string& product, const std::string& product,
std::chrono::system_clock::time_point latestTime) std::chrono::system_clock::time_point latestTime)
{ {
@ -817,10 +817,11 @@ void MapWidgetImpl::RadarProductManagerConnect()
std::make_shared<request::NexradFileRequest>(); std::make_shared<request::NexradFileRequest>();
// File request callback // File request callback
connect(request.get(), connect(
request.get(),
&request::NexradFileRequest::RequestComplete, &request::NexradFileRequest::RequestComplete,
this, this,
[&](std::shared_ptr<request::NexradFileRequest> request) [this](std::shared_ptr<request::NexradFileRequest> request)
{ {
// Select loaded record // Select loaded record
auto record = request->radar_product_record(); auto record = request->radar_product_record();
@ -833,7 +834,7 @@ void MapWidgetImpl::RadarProductManagerConnect()
// Load file // Load file
scwx::util::async( scwx::util::async(
[=]() [=, this]()
{ {
if (group == common::RadarProductGroup::Level2) if (group == common::RadarProductGroup::Level2)
{ {
@ -867,7 +868,7 @@ void MapWidgetImpl::InitializeNewRadarProductView(
const std::string& colorPalette) const std::string& colorPalette)
{ {
scwx::util::async( scwx::util::async(
[=]() [=, this]()
{ {
auto radarProductView = context_->radar_product_view(); auto radarProductView = context_->radar_product_view();
@ -903,13 +904,13 @@ void MapWidgetImpl::RadarProductViewConnect()
radarProductView.get(), radarProductView.get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableUpdated,
this, this,
[&]() { widget_->update(); }, [this]() { widget_->update(); },
Qt::QueuedConnection); Qt::QueuedConnection);
connect( connect(
radarProductView.get(), radarProductView.get(),
&view::RadarProductView::SweepComputed, &view::RadarProductView::SweepComputed,
this, this,
[=]() [=, this]()
{ {
std::shared_ptr<config::RadarSite> radarSite = std::shared_ptr<config::RadarSite> radarSite =
radarProductManager_->radar_site(); radarProductManager_->radar_site();

View file

@ -149,11 +149,11 @@ void RadarProductLayer::Initialize()
connect(radarProductView.get(), connect(radarProductView.get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableUpdated,
this, this,
[=]() { p->colorTableNeedsUpdate_ = true; }); [this]() { p->colorTableNeedsUpdate_ = true; });
connect(radarProductView.get(), connect(radarProductView.get(),
&view::RadarProductView::SweepComputed, &view::RadarProductView::SweepComputed,
this, this,
[=]() { p->sweepNeedsUpdate_ = true; }); [this]() { p->sweepNeedsUpdate_ = true; });
} }
void RadarProductLayer::UpdateSweep() void RadarProductLayer::UpdateSweep()

View file

@ -108,7 +108,7 @@ void AlertProxyModelImpl::UpdateAlerts()
using namespace std::chrono; using namespace std::chrono;
alertUpdateTimer_.expires_after(15s); alertUpdateTimer_.expires_after(15s);
alertUpdateTimer_.async_wait( alertUpdateTimer_.async_wait(
[=](const boost::system::error_code& e) [this](const boost::system::error_code& e)
{ {
if (e == boost::asio::error::operation_aborted) if (e == boost::asio::error::operation_aborted)
{ {

View file

@ -47,7 +47,7 @@ RadarProductModelImpl::RadarProductModelImpl(RadarProductModel* self) :
&manager::RadarProductManagerNotifier::Instance(), &manager::RadarProductManagerNotifier::Instance(),
&manager::RadarProductManagerNotifier::RadarProductManagerCreated, &manager::RadarProductManagerNotifier::RadarProductManagerCreated,
this, this,
[=](const std::string& radarSite) [this](const std::string& radarSite)
{ {
logger_->debug("Adding radar site: {}", radarSite); logger_->debug("Adding radar site: {}", radarSite);
@ -67,7 +67,7 @@ RadarProductModelImpl::RadarProductModelImpl(RadarProductModel* self) :
manager::RadarProductManager::Instance(radarSite).get(), manager::RadarProductManager::Instance(radarSite).get(),
&manager::RadarProductManager::NewDataAvailable, &manager::RadarProductManager::NewDataAvailable,
this, this,
[=](common::RadarProductGroup group, [=, this](common::RadarProductGroup group,
const std::string& product, const std::string& product,
std::chrono::system_clock::time_point latestTime) std::chrono::system_clock::time_point latestTime)
{ {

View file

@ -74,7 +74,7 @@ void AlertDialogImpl::ConnectSignals()
textEventManager_.get(), textEventManager_.get(),
&manager::TextEventManager::AlertUpdated, &manager::TextEventManager::AlertUpdated,
this, this,
[=](const types::TextEventKey& key) [this](const types::TextEventKey& key)
{ {
if (key == key_) if (key == key_)
{ {
@ -85,7 +85,7 @@ void AlertDialogImpl::ConnectSignals()
connect(goButton_, connect(goButton_,
&QPushButton::clicked, &QPushButton::clicked,
this, this,
[=]() [this]()
{ {
emit self_->MoveMap(centroid_.latitude_, centroid_.longitude_); emit self_->MoveMap(centroid_.latitude_, centroid_.longitude_);
self_->close(); self_->close();

View file

@ -127,10 +127,11 @@ void AlertDockWidgetImpl::ConnectSignals()
alertModel_.get(), alertModel_.get(),
&model::AlertModel::HandleAlert, &model::AlertModel::HandleAlert,
Qt::QueuedConnection); Qt::QueuedConnection);
connect(self_->ui->alertView->selectionModel(), connect(
self_->ui->alertView->selectionModel(),
&QItemSelectionModel::selectionChanged, &QItemSelectionModel::selectionChanged,
this, this,
[=](const QItemSelection& selected, const QItemSelection& deselected) [this](const QItemSelection& selected, const QItemSelection& deselected)
{ {
if (selected.size() == 0 && deselected.size() == 0) if (selected.size() == 0 && deselected.size() == 0)
{ {
@ -149,8 +150,7 @@ void AlertDockWidgetImpl::ConnectSignals()
QModelIndex selectedIndex = QModelIndex selectedIndex =
proxyModel_->mapToSource(selected[0].indexes()[0]); proxyModel_->mapToSource(selected[0].indexes()[0]);
selectedAlertKey_ = alertModel_->key(selectedIndex); selectedAlertKey_ = alertModel_->key(selectedIndex);
selectedAlertCentroid_ = selectedAlertCentroid_ = alertModel_->centroid(selectedAlertKey_);
alertModel_->centroid(selectedAlertKey_);
itemHasCoordinates = itemHasCoordinates =
selectedAlertCentroid_ != common::Coordinate {}; selectedAlertCentroid_ != common::Coordinate {};
} }
@ -168,7 +168,7 @@ void AlertDockWidgetImpl::ConnectSignals()
connect(self_->ui->alertViewButton, connect(self_->ui->alertViewButton,
&QPushButton::clicked, &QPushButton::clicked,
this, this,
[=]() [this]()
{ {
// View alert // View alert
alertDialog_->SelectAlert(selectedAlertKey_); alertDialog_->SelectAlert(selectedAlertKey_);
@ -177,7 +177,7 @@ void AlertDockWidgetImpl::ConnectSignals()
connect(self_->ui->alertGoButton, connect(self_->ui->alertGoButton,
&QPushButton::clicked, &QPushButton::clicked,
this, this,
[=]() [this]()
{ {
emit self_->MoveMap(selectedAlertCentroid_.latitude_, emit self_->MoveMap(selectedAlertCentroid_.latitude_,
selectedAlertCentroid_.longitude_); selectedAlertCentroid_.longitude_);

View file

@ -45,7 +45,7 @@ ImGuiDebugDialog::ImGuiDebugDialog(QWidget* parent) :
connect( connect(
ui->contextComboBox, ui->contextComboBox,
&QComboBox::currentIndexChanged, &QComboBox::currentIndexChanged,
[=](int row) [this](int row)
{ {
auto& contextModel = model::ImGuiContextModel::Instance(); auto& contextModel = model::ImGuiContextModel::Instance();
auto index = contextModel.index(row, 0); auto index = contextModel.index(row, 0);

View file

@ -39,7 +39,7 @@ public:
QObject::connect(toolButton, QObject::connect(toolButton,
&QToolButton::clicked, &QToolButton::clicked,
this, this,
[=]() { SelectProduct(product); }); [=, this]() { SelectProduct(product); });
} }
} }
~Level2ProductsWidgetImpl() = default; ~Level2ProductsWidgetImpl() = default;

View file

@ -179,7 +179,7 @@ void Level2SettingsWidget::UpdateSettings(map::MapWidget* activeMap)
connect(toolButton, connect(toolButton,
&QToolButton::clicked, &QToolButton::clicked,
this, this,
[=]() { p->SelectElevation(elevationCut); }); [=, this]() { p->SelectElevation(elevationCut); });
} }
p->elevationCuts_ = elevationCuts; p->elevationCuts_ = elevationCuts;

View file

@ -48,7 +48,7 @@ public:
QObject::connect(toolButton, QObject::connect(toolButton,
&QToolButton::clicked, &QToolButton::clicked,
this, this,
[=]() { SelectProductCategory(category); }); [=, this]() { SelectProductCategory(category); });
QMenu* categoryMenu = new QMenu(); QMenu* categoryMenu = new QMenu();
toolButton->setMenu(categoryMenu); toolButton->setMenu(categoryMenu);
@ -79,7 +79,7 @@ public:
action, action,
&QAction::triggered, &QAction::triggered,
this, this,
[=]() [=, this]()
{ {
std::shared_lock lock {awipsProductMutex_}; std::shared_lock lock {awipsProductMutex_};
std::string awipsProductName {awipsProductMap_.at(action)}; std::string awipsProductName {awipsProductMap_.at(action)};

View file

@ -72,11 +72,12 @@ RadarSiteDialog::RadarSiteDialog(QWidget* parent) :
connect(ui->radarSiteView, connect(ui->radarSiteView,
&QTreeView::doubleClicked, &QTreeView::doubleClicked,
this, this,
[=]() { emit accept(); }); [this]() { emit accept(); });
connect(ui->radarSiteView->selectionModel(), connect(
ui->radarSiteView->selectionModel(),
&QItemSelectionModel::selectionChanged, &QItemSelectionModel::selectionChanged,
this, this,
[=](const QItemSelection& selected, const QItemSelection& deselected) [this](const QItemSelection& selected, const QItemSelection& deselected)
{ {
if (selected.size() == 0 && deselected.size() == 0) if (selected.size() == 0 && deselected.size() == 0)
{ {
@ -97,18 +98,17 @@ RadarSiteDialog::RadarSiteDialog(QWidget* parent) :
QVariant variantData = p->radarSiteModel_->data(selectedIndex); QVariant variantData = p->radarSiteModel_->data(selectedIndex);
if (variantData.typeId() == QMetaType::QString) if (variantData.typeId() == QMetaType::QString)
{ {
p->selectedRadarSite_ = p->selectedRadarSite_ = variantData.toString().toStdString();
variantData.toString().toStdString();
} }
else else
{ {
logger_->warn("Unexpected selection data type"); logger_->warn("Unexpected selection data type");
p->selectedRadarSite_ = "?"; p->selectedRadarSite_ = std::string {"?"};
} }
} }
else else
{ {
p->selectedRadarSite_ = "?"; p->selectedRadarSite_ = std::string {"?"};
} }
logger_->debug("Selected: {}", p->selectedRadarSite_); logger_->debug("Selected: {}", p->selectedRadarSite_);

View file

@ -514,11 +514,13 @@ void SettingsDialogImpl::SetupPalettesAlertsTab()
QObject::connect(activeButton, QObject::connect(activeButton,
&QAbstractButton::clicked, &QAbstractButton::clicked,
self_, self_,
[=]() { ShowColorDialog(activeEdit, activeFrame); }); [=, this]()
{ ShowColorDialog(activeEdit, activeFrame); });
QObject::connect(inactiveButton, QObject::connect(inactiveButton,
&QAbstractButton::clicked, &QAbstractButton::clicked,
self_, self_,
[=]() { ShowColorDialog(inactiveEdit, inactiveFrame); }); [=, this]()
{ ShowColorDialog(inactiveEdit, inactiveFrame); });
} }
} }

View file

@ -292,7 +292,7 @@ void Level2ProductViewImpl::SetProduct(common::Level2Product product)
void Level2ProductView::Update() void Level2ProductView::Update()
{ {
util::async([=]() { ComputeSweep(); }); util::async([this]() { ComputeSweep(); });
} }
void Level2ProductView::UpdateColorTable() void Level2ProductView::UpdateColorTable()

View file

@ -163,7 +163,7 @@ void Level3ProductView::LoadColorTable(
void Level3ProductView::Update() void Level3ProductView::Update()
{ {
util::async([=]() { ComputeSweep(); }); util::async([this]() { ComputeSweep(); });
} }
void Level3ProductView::UpdateColorTable() void Level3ProductView::UpdateColorTable()