settings: fix proxy switch crash

This commit is contained in:
tobtoht 2024-05-03 01:26:03 +02:00
parent b030c7d032
commit 9483325a68
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
4 changed files with 11 additions and 11 deletions

View file

@ -89,9 +89,7 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
connect(m_windowManager, &WindowManager::websocketStatusChanged, this, &MainWindow::onWebsocketStatusChanged);
this->onWebsocketStatusChanged(!conf()->get(Config::disableWebsocket).toBool());
connect(m_windowManager, &WindowManager::proxySettingsChanged, [this]{
this->onProxySettingsChanged();
});
connect(m_windowManager, &WindowManager::proxySettingsChanged, this, &MainWindow::onProxySettingsChangedConnect);
connect(m_windowManager, &WindowManager::updateBalance, m_wallet, &Wallet::updateBalance);
connect(m_windowManager, &WindowManager::offlineMode, this, &MainWindow::onOfflineMode);
connect(m_windowManager, &WindowManager::manualFeeSelectionEnabled, this, &MainWindow::onManualFeeSelectionEnabled);
@ -183,7 +181,7 @@ void MainWindow::initStatusBar() {
m_statusBtnProxySettings = new StatusBarButton(icons()->icon("tor_logo_disabled.png"), "Proxy settings", this);
connect(m_statusBtnProxySettings, &StatusBarButton::clicked, this, &MainWindow::menuProxySettingsClicked);
this->statusBar()->addPermanentWidget(m_statusBtnProxySettings);
this->onProxySettingsChanged(false);
this->onProxySettingsChanged();
m_statusBtnHwDevice = new StatusBarButton(this->hardwareDevicePairedIcon(), this->getHardwareDevice(), this);
connect(m_statusBtnHwDevice, &StatusBarButton::clicked, this, &MainWindow::menuHwDeviceClicked);
@ -651,11 +649,12 @@ void MainWindow::onWebsocketStatusChanged(bool enabled) {
m_sendWidget->setWebsocketEnabled(enabled);
}
void MainWindow::onProxySettingsChanged(bool connect) {
if (connect) {
void MainWindow::onProxySettingsChangedConnect() {
m_nodes->connectToNode();
this->onProxySettingsChanged();
}
void MainWindow::onProxySettingsChanged() {
int proxy = conf()->get(Config::proxy).toInt();
if (proxy == Config::Proxy::Tor) {

View file

@ -165,7 +165,8 @@ private slots:
void tryStoreWallet();
void onWebsocketStatusChanged(bool enabled);
void showUpdateNotification();
void onProxySettingsChanged(bool connect = true);
void onProxySettingsChangedConnect();
void onProxySettingsChanged();
void onOfflineMode(bool offline);
void onManualFeeSelectionEnabled(bool enabled);
void onSubtractFeeFromAmountEnabled(bool enabled);

View file

@ -378,6 +378,7 @@ void Settings::onProxySettingsChanged() {
ui->closeButton->addButton(QDialogButtonBox::Apply);
connect(ui->closeButton->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, [this](){
ui->proxyWidget->setProxySettings();
m_nodes->updateModels();
emit proxySettingsChanged();
ui->closeButton->removeButton(ui->closeButton->button(QDialogButtonBox::Apply));
});

View file

@ -134,7 +134,6 @@ struct FeatherNode {
}
};
class AppContext;
class Nodes : public QObject {
Q_OBJECT
@ -144,6 +143,7 @@ public:
void loadConfig();
void allowConnection();
void updateModels();
NodeSource source();
FeatherNode connection();
@ -190,7 +190,6 @@ private:
bool useI2PNodes();
bool useSocks5Proxy(const FeatherNode &node);
void updateModels();
void resetLocalState();
void exhausted();
int modeHeight(const QList<FeatherNode> &nodes);