From 955ab04bbf278eb8d4753b299ab6177450e06eb2 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 22 Mar 2020 21:32:53 -0700 Subject: [PATCH] Clean up watchdog thread when quitting, which avoids segfaults --- onionshare_gui/main_window.py | 4 +--- onionshare_gui/tab_widget.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/onionshare_gui/main_window.py b/onionshare_gui/main_window.py index 0c9b179c..1c745b1c 100644 --- a/onionshare_gui/main_window.py +++ b/onionshare_gui/main_window.py @@ -284,7 +284,5 @@ class MainWindow(QtWidgets.QMainWindow): e.accept() def cleanup(self): - for index in range(self.tabs.count()): - tab = self.tabs.widget(index) - tab.cleanup() + self.tabs.cleanup() self.common.gui.onion.cleanup() diff --git a/onionshare_gui/tab_widget.py b/onionshare_gui/tab_widget.py index be744ace..d69931c0 100644 --- a/onionshare_gui/tab_widget.py +++ b/onionshare_gui/tab_widget.py @@ -79,6 +79,16 @@ class TabWidget(QtWidgets.QTabWidget): self.observer.schedule(self.event_handler, self.common.gui.events_dir) self.observer.start() + def cleanup(self): + # Stop the event thread + self.observer.stop() + self.observer.join() + + # Clean up each tab + for index in range(self.count()): + tab = self.widget(index) + tab.cleanup() + def move_new_tab_button(self): # Find the width of all tabs tabs_width = sum(