[Qt] Got rid of qt.util.Timer class and instead replaced the functionality with the more efficient QTimer. Also added disconnection from the timer on window close.

(cherry picked from 19a21eb08d)
This commit is contained in:
Calin Culianu 2018-12-12 00:53:55 +02:00 committed by SomberNight
parent 3184d6f369
commit 14363f8f2f
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
3 changed files with 8 additions and 18 deletions

View file

@ -105,7 +105,11 @@ class ElectrumGui(PrintError):
self.efilter = OpenFileEventFilter(self.windows)
self.app = QElectrumApplication(sys.argv)
self.app.installEventFilter(self.efilter)
self.timer = Timer()
# timer
self.timer = QTimer(self.app)
self.timer.setSingleShot(False)
self.timer.setInterval(500) # msec
self.nd = None
self.network_updated_signal_obj = QNetworkUpdatedSignalObject()
self._num_wizards_in_progress = 0

View file

@ -222,7 +222,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
# update fee slider in case we missed the callback
self.fee_slider.update()
self.load_wallet(wallet)
self.connect_slots(gui_object.timer)
gui_object.timer.timeout.connect(self.timer_actions)
self.fetch_alias()
def on_history(self, b):
@ -670,9 +670,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.config.set_key('io_dir', os.path.dirname(fileName), True)
return fileName
def connect_slots(self, sender):
sender.timer_signal.connect(self.timer_actions)
def timer_actions(self):
# Note this runs in the GUI thread
if self.need_update.is_set():
@ -3134,6 +3131,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if self.qr_window:
self.qr_window.close()
self.close_wallet()
self.gui_object.timer.timeout.disconnect(self.timer_actions)
self.gui_object.close_window(self)
def plugins_dialog(self):

View file

@ -48,19 +48,6 @@ expiration_values = [
]
class Timer(QThread):
stopped = False
timer_signal = pyqtSignal()
def run(self):
while not self.stopped:
self.timer_signal.emit()
time.sleep(0.5)
def stop(self):
self.stopped = True
self.wait()
class EnterButton(QPushButton):
def __init__(self, text, func):
QPushButton.__init__(self, text)