Skip to content

Commit

Permalink
FIX: fix saving session after interactive prealignment
Browse files Browse the repository at this point in the history
  • Loading branch information
leloup314 committed Jan 17, 2018
1 parent 1b61cee commit ee48612
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 5 additions & 3 deletions testbeam_analysis/gui/gui_widgets/analysis_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,11 @@ def _delete_option(self, option, func):
Delete existing option. Needed if option is set manually.
"""

# Delete option widget
self.option_widgets[option].close()
del self.option_widgets[option]
# If option is not fixed, delete corresponding widget
if option in self.option_widgets:
# Delete option widget
self.option_widgets[option].close()
del self.option_widgets[option]
# Update widgets
self.opt_optional.update()
self.opt_needed.update()
Expand Down
12 changes: 11 additions & 1 deletion testbeam_analysis/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,15 @@ def save_session(self):
Opens a dialog and safes current session
"""

try:
if self.tw[self.current_analysis_tab()].analysis_thread.isRunning():
msg = 'Can not safe while %s analysis is running.' % self.current_analysis_tab()
logging.error(msg=msg)
self.console_dock.setVisible(True)
return
except AttributeError:
pass

# Path to sessions directory in output_path
sessions_dir = os.path.join(self.options['output_path'], 'sessions')

Expand Down Expand Up @@ -591,7 +600,8 @@ def load_session(self):
try:
if self.tw[self.current_analysis_tab()].analysis_thread.isRunning():
msg = 'Can not load while %s analysis is running.' % self.current_analysis_tab()
logging.warning(msg=msg)
logging.error(msg=msg)
self.console_dock.setVisible(True)
return
except AttributeError:
pass
Expand Down
3 changes: 3 additions & 0 deletions testbeam_analysis/gui/tab_widgets/analysis_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,15 @@ def listen(self):
listener.closeSignal.connect(self.thread.quit)
self.thread.finished.connect(listener.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
# Important to delete to not safe in calls because queue has thread lock
self.thread.finished.connect(lambda: self._delete_option(option='queue', func=prealignment))

self.add_option(option='queue',
default_value=io,
func=prealignment,
fixed=True,
hidden=True)

self.thread.start()

self._call_funcs()
Expand Down

0 comments on commit ee48612

Please sign in to comment.