Skip to content

fix(SerializedFile): load dependencies as dependencies - #392

Open
nichinichisou0609 wants to merge 1 commit into
K0lb3:masterfrom
nichinichisou0609:fix/load-dependencies
Open

nichinichisou0609 wants to merge 1 commit into
K0lb3:masterfrom
nichinichisou0609:fix/load-dependencies

Conversation

@nichinichisou0609

Copy link
Copy Markdown
Contributor

SerializedFile.load_dependencies calls environment.load_file(path, True), which passes True as the parent argument of load_file, so is_dependency stays False. get_resource_data calls load_dependencies when the resource file of a texture, mesh or audio clip is not loaded yet, which then loads every external of the file as if the user had loaded it: their objects show up in Environment.objects next to the objects of the loaded file, and a loop over env.objects that runs again after reading such data also goes through the objects of the externals.

is_dependency=True is now passed by keyword, so the externals still resolve references and resources but are no longer listed as objects.

tests/test_dependencies.py (new) writes two copies of a sample serialized file to a temporary directory, the first listing the second as an external, loads the first and checks that load_dependencies() leaves Environment.objects as it was and marks the loaded external as a dependency.

Validation on Windows x86_64, CPython 3.11.13, pytest 9.1.1. The compiled path uses the UnityPyBoost extension of the 1.25.4 wheel; UnityPyBoost/ has no changes between 1.25.4 and 417d595. This branch and #383 merge without conflicts.

Check Result
New test against unmodified 417d595 1 failed
Complete suite, with / without the extension 49 passed / 49 passed
ruff check and ruff format --check Passed
python -m pytest -q tests/test_dependencies.py
python -m pytest -q tests

load_dependencies called environment.load_file(path, True), which
passes True as the parent argument, so is_dependency stayed False. The
externals of a file, also the ones loaded while get_resource_data looks
for a resource file, were therefore treated as files the user loaded:
their objects showed up in Environment.objects next to the objects of
the loaded file.

is_dependency=True is now passed by keyword, so dependencies resolve
references and resources but are no longer listed as objects.

tests/test_dependencies.py writes two copies of a sample serialized file
to a temporary directory, the first listing the second as an external,
and checks that loading the dependency leaves Environment.objects as it
was.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant