From 61d35904ba9e77914dc14ebfc1e850015c1569e3 Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Thu, 14 Nov 2024 19:11:08 +0100 Subject: [PATCH] [core] Discard attribute callbacks during graph loading --- meshroom/core/graph.py | 13 +++++++++++++ meshroom/core/node.py | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index ebe2de1ba5..9fd07900c1 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -214,6 +214,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 @@ -246,6 +247,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): """ @@ -259,6 +265,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: diff --git a/meshroom/core/node.py b/meshroom/core/node.py index f6b4a85fe5..d206414d68 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -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)