From 3bdda3a8616fff8a1d53c4168e54a688f4961994 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 3 May 2023 12:18:34 +0000 Subject: [PATCH] config: force 'history_rates' config var to bool fixes https://github.com/spesmilo/electrum/issues/8367 probably regression from 503776c0dee2a544c0d746e9b853f29fe0b54279 (note that before that commit, we were casting to bool) --- electrum/exchange_rate.py | 4 ++-- electrum/gui/qml/qefx.py | 2 +- electrum/gui/qt/history_list.py | 2 +- electrum/gui/qt/my_treeview.py | 2 +- electrum/gui/qt/settings_dialog.py | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index 95adab7af..ea0a79ca7 100644 --- a/electrum/exchange_rate.py +++ b/electrum/exchange_rate.py @@ -592,8 +592,8 @@ class FxThread(ThreadJob, EventListener): def can_have_history(self): return self.is_enabled() and self.ccy in self.exchange.history_ccys() - def has_history(self): - return self.can_have_history() and self.config.get('history_rates', False) + def has_history(self) -> bool: + return self.can_have_history() and bool(self.config.get('history_rates', False)) def get_currency(self) -> str: '''Use when dynamic fetching is needed''' diff --git a/electrum/gui/qml/qefx.py b/electrum/gui/qml/qefx.py index 8a226e2d5..ce69cc304 100644 --- a/electrum/gui/qml/qefx.py +++ b/electrum/gui/qml/qefx.py @@ -63,7 +63,7 @@ class QEFX(QObject, QtEventListener): historicRatesChanged = pyqtSignal() @pyqtProperty(bool, notify=historicRatesChanged) def historicRates(self): - return self.fx.config.get('history_rates', True) + return bool(self.fx.config.get('history_rates', True)) @historicRates.setter def historicRates(self, checked): diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index cb4a2383f..284fac817 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -252,7 +252,7 @@ class HistoryModel(CustomModel, Logger): return True def should_show_fiat(self): - if not self.window.config.get('history_rates', False): + if not bool(self.window.config.get('history_rates', False)): return False fx = self.window.fx if not fx or not fx.is_enabled(): diff --git a/electrum/gui/qt/my_treeview.py b/electrum/gui/qt/my_treeview.py index 13918b075..b10674fde 100644 --- a/electrum/gui/qt/my_treeview.py +++ b/electrum/gui/qt/my_treeview.py @@ -83,7 +83,7 @@ class MyMenu(QMenu): b = self.config.get(name, default) m = self.addAction(text, lambda: self._do_toggle_config(name, default, callback)) m.setCheckable(True) - m.setChecked(b) + m.setChecked(bool(b)) m.setToolTip(tooltip) return m diff --git a/electrum/gui/qt/settings_dialog.py b/electrum/gui/qt/settings_dialog.py index 4fa16734f..4a4f59759 100644 --- a/electrum/gui/qt/settings_dialog.py +++ b/electrum/gui/qt/settings_dialog.py @@ -307,7 +307,7 @@ class SettingsDialog(QDialog, QtEventListener): def update_currencies(): if not self.fx: return - h = self.config.get('history_rates', False) + h = bool(self.config.get('history_rates', False)) currencies = sorted(self.fx.get_currencies(h)) ccy_combo.clear() ccy_combo.addItems([_('None')] + currencies) @@ -319,7 +319,7 @@ class SettingsDialog(QDialog, QtEventListener): b = self.fx.is_enabled() ex_combo.setEnabled(b) if b: - h = self.config.get('history_rates', False) + h = bool(self.config.get('history_rates', False)) c = self.fx.get_currency() exchanges = self.fx.get_exchanges_by_ccy(c, h) else: @@ -356,7 +356,7 @@ class SettingsDialog(QDialog, QtEventListener): update_currencies() update_exchanges() ccy_combo.currentIndexChanged.connect(on_currency) - self.history_rates_cb.setChecked(self.config.get('history_rates', False)) + self.history_rates_cb.setChecked(bool(self.config.get('history_rates', False))) self.history_rates_cb.stateChanged.connect(on_history_rates) ex_combo.currentIndexChanged.connect(on_exchange)