Change when the trace_blendfile() callback is called

Previously the `callback.trace_blendfile()` callback was called just before
tracing its dependencies would start, i.e. after opening it. This is now
changed to before opening it, because that can take a long time (to load
SDNA). this will make any UI (like the Flamenco add-on) report the right
filename when waiting for big files, instead of lingering on the
last-opened (potentially very small) blend file.
This commit is contained in:
Sybren A. Stüvel
2022-09-12 15:06:08 +02:00
parent bef5fb88cd
commit cc4043969e
3 changed files with 13 additions and 5 deletions
+1 -3
View File
@@ -49,12 +49,10 @@ def deps(
:param progress_cb: Progress callback object.
"""
log.info("opening: %s", bfilepath)
bfile = blendfile.open_cached(bfilepath)
bi = file2blocks.BlockIterator()
if progress_cb:
bi.progress_cb = progress_cb
bfile = bi.open_blendfile(bfilepath)
# Remember which block usages we've reported already, without keeping the
# blocks themselves in memory.
+8 -2
View File
@@ -65,6 +65,13 @@ class BlockIterator:
self.progress_cb = progress.Callback()
def open_blendfile(self, bfilepath: pathlib.Path) -> blendfile.BlendFile:
"""Open a blend file, sending notification about this to the progress callback."""
log.info("opening: %s", bfilepath)
self.progress_cb.trace_blendfile(bfilepath)
return blendfile.open_cached(bfilepath)
def iter_blocks(
self,
bfile: blendfile.BlendFile,
@@ -72,7 +79,6 @@ class BlockIterator:
) -> typing.Iterator[blendfile.BlendFileBlock]:
"""Expand blocks with dependencies from other libraries."""
self.progress_cb.trace_blendfile(bfile.filepath)
log.info("inspecting: %s", bfile.filepath)
if limit_to:
self._queue_named_blocks(bfile, limit_to)
@@ -127,7 +133,7 @@ class BlockIterator:
continue
log.debug("Expanding %d blocks in %s", len(idblocks), lib_path)
libfile = blendfile.open_cached(lib_path)
libfile = self.open_blendfile(lib_path)
yield from self.iter_blocks(libfile, idblocks)
def _queue_all_blocks(self, bfile: blendfile.BlendFile):