From 6ab6ea564a08080040da032ebf4da734996e7419 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 13 Jan 2018 22:46:57 -0800 Subject: [PATCH] Create the timer before the TorConnectionDialog dialog, but start it after. This way if you cancel the dialog, then click save in the settings, OnionShareGui.timer will already exist, even though though TorConnectionDialog hasn't closed yet --- onionshare_gui/onionshare_gui.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index c6e2dcc2..c056a32d 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -136,15 +136,17 @@ class OnionShareGui(QtWidgets.QMainWindow): # The server isn't active yet self.set_server_active(False) + # Create the timer + self.timer = QtCore.QTimer() + self.timer.timeout.connect(self.check_for_requests) + # Start the "Connecting to Tor" dialog, which calls onion.connect() tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion) tor_con.canceled.connect(self._tor_connection_canceled) tor_con.open_settings.connect(self._tor_connection_open_settings) tor_con.start() - # Check for requests frequently - self.timer = QtCore.QTimer() - self.timer.timeout.connect(self.check_for_requests) + # Start the timer self.timer.start(500) # After connecting to Tor, check for updates @@ -224,7 +226,7 @@ class OnionShareGui(QtWidgets.QMainWindow): # connection. If so, restart the timer. if self.onion.is_authenticated(): if not self.timer.isActive(): - self.timer.start() + self.timer.start(500) # If there were some files listed for sharing, we should be ok to # re-enable the 'Start Sharing' button now. if self.server_status.file_selection.get_num_files() > 0: