[ui] Clear locally submitted nodes before loading a new graph

When loading a new graph while the opened one was locally computing nodes,
computations were automatically stopped to be able to load the new graph.
However, the computing chunks' status were not being updated before
the graphs were switched up. This meant that opening that previously
computing graph again would lead to a display in which nodes appeared to
be computing although there was no ongoing computations.
This commit is contained in:
Candice Bentéjac 2022-11-28 09:42:08 +01:00
parent 1cd4ffc081
commit b08f83552e
3 changed files with 14 additions and 0 deletions

View file

@ -1366,6 +1366,11 @@ class Graph(BaseObject):
for node in self.nodes:
node.clearSubmittedChunks()
def clearLocallySubmittedNodes(self):
""" Reset the status of already locally submitted nodes to Status.NONE """
for node in self.nodes:
node.clearLocallySubmittedChunks()
def iterChunksByStatus(self, status):
""" Iterate over NodeChunks with the given status """
for node in self.nodes:

View file

@ -779,6 +779,12 @@ class BaseNode(BaseObject):
if chunk.isAlreadySubmitted():
chunk.upgradeStatusTo(Status.NONE, ExecMode.NONE)
def clearLocallySubmittedChunks(self):
""" Reset all locally submitted chunks to Status.NONE. """
for chunk in self._chunks:
if chunk.isAlreadySubmitted() and not chunk.isExtern():
chunk.upgradeStatusTo(Status.NONE, ExecMode.NONE)
def upgradeStatusTo(self, newStatus):
"""
Upgrade node to the given status and save it on disk.

View file

@ -284,6 +284,9 @@ class UIGraph(QObject):
""" Set the internal graph. """
if self._graph:
self.stopExecution()
# Clear all the locally submitted nodes at once before the graph gets changed, as it won't receive further updates
if self._computingLocally:
self._graph.clearLocallySubmittedNodes()
self.clear()
oldGraph = self._graph
self._graph = g