Skip to content
Snippets Groups Projects
Commit cbb0074e authored by Allen, Bruce (CIV)'s avatar Allen, Bruce (CIV)
Browse files

clear graphs while the trace generator is running

parent 01a3d6da
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,17 @@ class GraphsManager(QAbstractTableModel):
def clear_graphs(self):
self.set_graphs("", [], 1) # code, graphs, scope
def restore_graphs(self, existing_graphs, existing_scope):
if self.graphs:
raise RuntimeError("bad")
self.beginResetModel() # because self.graphs change
self.graphs = existing_graphs
self.scope = existing_scope
self.endResetModel()
# signal
self.signal_graphs_loaded.emit()
def has_non_empty_global_view(self):
return bool(self.graphs and self.graphs[0].has_non_trace())
......
......@@ -717,15 +717,20 @@ class GUIManager(QObject):
# compile MP Code
def _request_compile_mp_code(self):
# compile
# state at start of compilation
self._proposed_mp_code = self.mp_code_manager.mp_code_text
self._proposed_scope = self.scope_spinner.scope()
self._proposed_schema_name = self.mp_code_manager.mp_code_schema
self._proposed_settings = settings.copy()
self._existing_graphs = self.graphs_manager.graphs
self._existing_scope = self.graphs_manager.scope
self._existing_selected_graph_index \
= self.graph_list_view.selected_graph_index()
# set visual state
self.set_is_compiling(True)
# begin compilation
action = "Compiling %s scope %d..."%(self._proposed_schema_name,
self._proposed_scope)
log_to_statusbar(action)
......@@ -735,6 +740,10 @@ class GUIManager(QObject):
self._proposed_scope,
self._proposed_mp_code)
# clear the selected graph and the graphs
self.graph_list_view.select_graph_index(-1)
self.graphs_manager.clear_graphs()
# receive trace-generated json from the compiled MP Code
@Slot(str, dict, str)
def response_compile_mp_code(self, status, tg_data, _log):
......@@ -811,10 +820,16 @@ class GUIManager(QObject):
# cancel compile MP Code
def _cancel_compile_mp_code(self):
# cancel
# cancel compilation
log("Canceling compiling %s" % self._proposed_schema_name)
self.trace_generator_manager.mp_cancel_compile()
# restore graphs and the selected graph
self.graphs_manager.restore_graphs(self._existing_graphs,
self._existing_scope)
self.graph_list_view.select_graph_index(
self._existing_selected_graph_index)
def _run_cancel_compile_mp_code(self):
if self._is_compiling:
self._cancel_compile_mp_code()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment