Fix node states after loading

The states of nodes were not valid the first time they were loaded, but
became valid after any topological update (such as creating or removing
a node or edge).
The reason was that the loading of the graph was done before setting the
project path (and thus the cacheDir). So the status files of the nodes
were not available during the graph creation and were not updated at the
end of the load.
Now we set the filepath/cache first, so everything is right from the
start.
This commit is contained in:
Fabien Castan 2025-04-14 22:45:47 +02:00
parent be43c5c2a7
commit ff9a0370ac
2 changed files with 5 additions and 3 deletions

View file

@ -252,8 +252,8 @@ class Graph(BaseObject):
Args:
filepath: The path to the Meshroom Graph file to load.
"""
self._deserialize(Graph._loadGraphData(filepath))
self._setFilepath(filepath)
self._deserialize(Graph._loadGraphData(filepath))
self._fileDateVersion = os.path.getmtime(filepath)
def initFromTemplate(self, filepath: PathLike, publishOutputs: bool = False):
@ -293,7 +293,9 @@ class Graph(BaseObject):
Args:
graphData: The serialized Graph.
"""
self.clear()
self._clearGraphContent()
self.header.clear()
self.header = graphData.get(GraphIO.Keys.Header, {})
fileVersion = Version(self.header.get(GraphIO.Keys.FileVersion, "0.0"))
graphContent = self._normalizeGraphContent(graphData, fileVersion)

View file

@ -952,7 +952,7 @@ class BaseNode(BaseObject):
def nbParallelizationBlocks(self):
return len(self._chunks)
def hasStatus(self, status):
def hasStatus(self, status: Status):
if not self._chunks:
return (status == Status.INPUT)
for chunk in self._chunks: