Skip to content

Commit

Permalink
Fix: avoid destroying QThread object before it can finish
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Jul 6, 2023
1 parent 9cc07fa commit 6d1cc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 4 additions & 2 deletions damnit/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ def _menu_bar_help(self) -> None:
dialog.exec()

def _menu_bar_autoconfigure(self) -> None:
context_dir, prop_no = OpenDBDialog.run_get_result(parent=self)
open_dialog = OpenDBDialog(self)
context_dir, prop_no = open_dialog.run_get_result()
if context_dir is None:
return
if not prompt_setup_db_and_backend(context_dir, prop_no, parent=self):
Expand Down Expand Up @@ -1011,7 +1012,8 @@ def run_app(context_dir, connect_to_kafka=True):
application.setStyle(TableViewStyle())

if context_dir is None:
context_dir, prop_no = OpenDBDialog.run_get_result()
open_dialog = OpenDBDialog()
context_dir, prop_no = open_dialog.run_get_result()
if context_dir is None:
return 0
if not prompt_setup_db_and_backend(context_dir, prop_no):
Expand Down
8 changes: 3 additions & 5 deletions damnit/gui/open_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ def __init__(self, parent=None):
self.finished.connect(self.proposal_finder_thread.quit)
self.proposal_finder_thread.start()

@staticmethod
def run_get_result(parent=None) -> (Optional[Path], Optional[int]):
dlg = OpenDBDialog(parent)
if dlg.exec() == QDialog.Rejected:
def run_get_result(self) -> (Optional[Path], Optional[int]):
if self.exec() == QDialog.Rejected:
return None, None
return dlg.get_chosen_dir(), dlg.get_proposal_num()
return self.get_chosen_dir(), self.get_proposal_num()

def proposal_dir_result(self, propnum: str, dir: str):
if propnum != self.ui.proposal_edit.text():
Expand Down

0 comments on commit 6d1cc27

Please sign in to comment.