summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-11-09 20:09:56 -0800
committerMicah Lee <micah@micahflee.com>2020-11-09 20:09:56 -0800
commit09d1118a945620487e67ea70ddff9b145399d4ff (patch)
treeb437723288ad69f0f8fbcbe4cde9de74913c7a15
parentf67e7ce67885dea4a8ed308fbffd84108a08ec22 (diff)
downloadonionshare-09d1118a945620487e67ea70ddff9b145399d4ff.tar.gz
onionshare-09d1118a945620487e67ea70ddff9b145399d4ff.zip
Only close web thread on cleanup if web thread exists, and sleep 1 second when cleaning up MainWindow so loose threads can finish
-rw-r--r--desktop/src/onionshare/main_window.py4
-rw-r--r--desktop/src/onionshare/tab/tab.py5
2 files changed, 7 insertions, 2 deletions
diff --git a/desktop/src/onionshare/main_window.py b/desktop/src/onionshare/main_window.py
index 38a6b275..c1e0cd1a 100644
--- a/desktop/src/onionshare/main_window.py
+++ b/desktop/src/onionshare/main_window.py
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
+import time
from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.web import Web
@@ -286,3 +287,6 @@ class MainWindow(QtWidgets.QMainWindow):
def cleanup(self):
self.tabs.cleanup()
self.common.gui.onion.cleanup()
+
+ # Wait 1 second for threads to close gracefully, so tests finally pass
+ time.sleep(1)
diff --git a/desktop/src/onionshare/tab/tab.py b/desktop/src/onionshare/tab/tab.py
index b5e4e6a8..5e819405 100644
--- a/desktop/src/onionshare/tab/tab.py
+++ b/desktop/src/onionshare/tab/tab.py
@@ -663,6 +663,7 @@ class Tab(QtWidgets.QWidget):
return False
def cleanup(self):
- self.get_mode().web_thread.quit()
- self.get_mode().web_thread.wait()
+ if self.get_mode() and self.get_mode().web_thread:
+ self.get_mode().web_thread.quit()
+ self.get_mode().web_thread.wait()
self.app.cleanup()