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:
parent
bef5fb88cd
commit
cc4043969e
@ -3,6 +3,10 @@
|
|||||||
This file logs the changes that are actually interesting to users (new features,
|
This file logs the changes that are actually interesting to users (new features,
|
||||||
changed functionality, fixed bugs).
|
changed functionality, fixed bugs).
|
||||||
|
|
||||||
|
# Version 1.14 (in development)
|
||||||
|
|
||||||
|
- While tracing dependencies, call the progress callback function before opening a blend file, instead of before iterating over its contents. The opening (and loading of SDNA) takes a significant amount of time, so this will make any UI (like the Flamenco add-on) report the right filename when waiting for big files.
|
||||||
|
|
||||||
# Version 1.13 (2022-07-14)
|
# Version 1.13 (2022-07-14)
|
||||||
|
|
||||||
- Improve an error message when packing fails. It now not only mentions that something went wrong, but also which file and which operation on that file (copy or move) was involved.
|
- Improve an error message when packing fails. It now not only mentions that something went wrong, but also which file and which operation on that file (copy or move) was involved.
|
||||||
|
|||||||
@ -49,12 +49,10 @@ def deps(
|
|||||||
:param progress_cb: Progress callback object.
|
:param progress_cb: Progress callback object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.info("opening: %s", bfilepath)
|
|
||||||
bfile = blendfile.open_cached(bfilepath)
|
|
||||||
|
|
||||||
bi = file2blocks.BlockIterator()
|
bi = file2blocks.BlockIterator()
|
||||||
if progress_cb:
|
if progress_cb:
|
||||||
bi.progress_cb = progress_cb
|
bi.progress_cb = progress_cb
|
||||||
|
bfile = bi.open_blendfile(bfilepath)
|
||||||
|
|
||||||
# Remember which block usages we've reported already, without keeping the
|
# Remember which block usages we've reported already, without keeping the
|
||||||
# blocks themselves in memory.
|
# blocks themselves in memory.
|
||||||
|
|||||||
@ -65,6 +65,13 @@ class BlockIterator:
|
|||||||
|
|
||||||
self.progress_cb = progress.Callback()
|
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(
|
def iter_blocks(
|
||||||
self,
|
self,
|
||||||
bfile: blendfile.BlendFile,
|
bfile: blendfile.BlendFile,
|
||||||
@ -72,7 +79,6 @@ class BlockIterator:
|
|||||||
) -> typing.Iterator[blendfile.BlendFileBlock]:
|
) -> typing.Iterator[blendfile.BlendFileBlock]:
|
||||||
"""Expand blocks with dependencies from other libraries."""
|
"""Expand blocks with dependencies from other libraries."""
|
||||||
|
|
||||||
self.progress_cb.trace_blendfile(bfile.filepath)
|
|
||||||
log.info("inspecting: %s", bfile.filepath)
|
log.info("inspecting: %s", bfile.filepath)
|
||||||
if limit_to:
|
if limit_to:
|
||||||
self._queue_named_blocks(bfile, limit_to)
|
self._queue_named_blocks(bfile, limit_to)
|
||||||
@ -127,7 +133,7 @@ class BlockIterator:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
log.debug("Expanding %d blocks in %s", len(idblocks), lib_path)
|
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)
|
yield from self.iter_blocks(libfile, idblocks)
|
||||||
|
|
||||||
def _queue_all_blocks(self, bfile: blendfile.BlendFile):
|
def _queue_all_blocks(self, bfile: blendfile.BlendFile):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user