@@ -410,16 +410,17 @@ void BitcoinGUI::createActions()
410410 QAction* action = m_open_wallet_menu->addAction (name);
411411
412412 if (loaded || is_legacy) {
413- // This wallet is already loaded or it is a legacy wallet
414413 action->setEnabled (false );
415414 continue ;
416415 }
417416
418- connect (action, &QAction::triggered, [this , path] {
417+ // Create a local copy of path to capture
418+ const auto captured_path = path;
419+ connect (action, &QAction::triggered, [this , captured_path] {
419420 auto activity = new OpenWalletActivity (m_wallet_controller, this );
420421 connect (activity, &OpenWalletActivity::opened, this , &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
421422 connect (activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
422- activity->open (path );
423+ activity->open (captured_path );
423424 });
424425 }
425426 if (m_open_wallet_menu->isEmpty ()) {
@@ -475,10 +476,12 @@ void BitcoinGUI::createActions()
475476 name.replace (QChar (' &' ), QString (" &&" ));
476477 QAction* action = m_migrate_wallet_menu->addAction (name);
477478
478- connect (action, &QAction::triggered, [this , wallet_name] {
479+ // Create a local copy of wallet_name to capture
480+ const auto captured_wallet_name = wallet_name;
481+ connect (action, &QAction::triggered, [this , captured_wallet_name] {
479482 auto activity = new MigrateWalletActivity (m_wallet_controller, this );
480483 connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
481- activity->migrate (wallet_name );
484+ activity->migrate (captured_wallet_name );
482485 });
483486 }
484487 if (m_migrate_wallet_menu->isEmpty ()) {
0 commit comments