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

This commit is contained in:
Micah Lee 2018-01-13 22:46:57 -08:00
parent 8f585db127
commit 6ab6ea564a
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -136,15 +136,17 @@ class OnionShareGui(QtWidgets.QMainWindow):
# The server isn't active yet # The server isn't active yet
self.set_server_active(False) 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() # Start the "Connecting to Tor" dialog, which calls onion.connect()
tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion) tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion)
tor_con.canceled.connect(self._tor_connection_canceled) tor_con.canceled.connect(self._tor_connection_canceled)
tor_con.open_settings.connect(self._tor_connection_open_settings) tor_con.open_settings.connect(self._tor_connection_open_settings)
tor_con.start() tor_con.start()
# Check for requests frequently # Start the timer
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.check_for_requests)
self.timer.start(500) self.timer.start(500)
# After connecting to Tor, check for updates # After connecting to Tor, check for updates
@ -224,7 +226,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
# connection. If so, restart the timer. # connection. If so, restart the timer.
if self.onion.is_authenticated(): if self.onion.is_authenticated():
if not self.timer.isActive(): 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 # If there were some files listed for sharing, we should be ok to
# re-enable the 'Start Sharing' button now. # re-enable the 'Start Sharing' button now.
if self.server_status.file_selection.get_num_files() > 0: if self.server_status.file_selection.get_num_files() > 0: