Skip to content

Commit

Permalink
[core] Discard attribute callbacks during graph loading
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-lty committed Nov 14, 2024
1 parent 87e538c commit 9acd7f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions meshroom/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def getFeaturesForVersion(fileVersion):
def __init__(self, name, parent=None):
super(Graph, self).__init__(parent)
self.name = name
self._loading = False
self._updateEnabled = True
self._updateRequested = False
self.dirtyTopology = False
Expand Down Expand Up @@ -247,6 +248,11 @@ def fileFeatures(self):
""" Get loaded file supported features based on its version. """
return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0"))

@property
def isLoading(self):
""" Return True if the graph is currently being loaded. """
return self._loading

@Slot(str)
def load(self, filepath, setupProjectFile=True, importProject=False, publishOutputs=False):
"""
Expand All @@ -260,6 +266,13 @@ def load(self, filepath, setupProjectFile=True, importProject=False, publishOutp
of opened.
publishOutputs: True if "Publish" nodes from templates should not be ignored.
"""
self._loading = True
try:
self._load(filepath, setupProjectFile, importProject, publishOutputs)
finally:
self._loading = False

def _load(self, filepath, setupProjectFile, importProject, publishOutputs):
if not importProject:
self.clear()
with open(filepath) as jsonFile:
Expand Down
4 changes: 4 additions & 0 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@ def _onAttributeChanged(self, attr: Attribute):
if attr.value is None:
# Discard dynamic values depending on the graph processing.
return

if self.graph and self.graph.isLoading:
# Do not trigger attribute callbacks during the graph loading.
return

callback = self._getAttributeChangedCallback(attr)

Expand Down

0 comments on commit 9acd7f8

Please sign in to comment.