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:
@@ -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.
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user