Repository navigation
fix(skills): re-register driver functions on file load - #411
Merged
Merged
Conversation
driver_namespace is reset on every file load. The skill and snippet registered the function only in register(), so the first file a user opens evaluates the driver without it: NameError, the driver is disabled (is_valid False), and it stays disabled even after the function is put back. Measured on 4.5.11 and 5.2.1: z went from 2.4621 to 0.0 across a save and reopen. Both now re-register from a @Persistent load_post handler that also resets driver.is_valid, with symmetric register/unregister. The skill's compatibility table and common-mistakes list say why. Closes #387 Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
CI evidence before merge: all checks pass ( 13 pass ). Blender Smoke on PR head: Blender 5.2.2 LTS / Blender 4.5.14 LTS. Summaries (happy path; falsifiers) per leg: 141 passed, 3 skipped, 0 failed;136 passed, 6 skipped, 0 failed;143 passed, 1 skipped, 0 failed;142 passed, 0 skipped, 0 failed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #387.
Problem
bpy.app.driver_namespaceis reset on every file load. The skill andsnippets/driver-with-custom-function.pyregistered the custom function only inregister(). On the first file a user opens:NameErrorand is disabled (driver.is_valid = False);Change
restore_driver_function(), a@persistentload_posthandler, re-registers the function and resetsis_validon drivers on objects, shape keys and materials;register()/unregister();Evidence
Proven by live run (
--factory-startup; binaries report 5.2.1 LTS and 4.5.11 LTS). The probe imports the real snippet, attaches its smoothstep driver, evaluates at frame 50, then doessave_as_mainfile→open_mainfile→ re-evaluates:is_validregister()(withload_posthandler)is_validresetBefore the save, z = 2.4621 in every mode. The last row shows why the
is_validreset is required, not just the re-registration.By inspection only: the snippet is 61 lines (limit 75).
🤖 Generated with Claude Code