bpy.utils.unregister_module doesn't unregister classes of submodules #50052
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#50052
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Short description of error
bpy.utils.register_module
register classes from submodules correctly, butbpy.utils.unregister_module
doesn't unregister them.I've attached example of a simple addon to check this.
Exact steps for others to reproduce the error
Download and unpack custom_scripts.zip
Scripts
path to point to the root directory calledcustom_scripts
pressSave User Settings
Test
Scripts
field andSave User Settings
Test
panel on theRender
tab is still present. You also can find the corresponding class in bpy.typesIf you will uncomment
bpy.utils.unregister_class(RenderTestPanel)
inui_render.py
and retry all steps, you will see the correct behaviorProbably it's an expected behavior
Changed status to: 'Open'
Added subscriber: @AlexanderRomanov
Added subscriber: @mont29
Changed status from 'Open' to: 'Archived'
I do not see any unexpected behavior here? When you clear script field, you just prevents Blender any further access to that addon, so it obviously cannot unregister or re-register that addon correctly anymore. Henceforth, all classes it defined during its last registration remain alive until next start of Blender.
If
bpy.utils.register_module
callsregister_class
for each submodule class,bpy.utils.unregister_module
must callunregister_class
for that submodules. This is what I am expecting. After clearingScripts
unregister_class
must be invoked fromunregister_module
, which is in memory currently; and yes, register will fail. But we see, thatunregister_class
is not called byunregister_module
, because the pannel is still present.You can see invocation of
unregister_class
, but generator_bpy_module_classes
returns nothing. Seems that the issue is in _bpy_types.TypeMap, or I missed something.PS Now it seems that you don't have to call
register_class
for all your classes, but you have to callunregister_class
Changed status from 'Archived' to: 'Open'
OK, confirmed the issue and found the culprit: in reload case (F8), TypeMap is cleared before calling unregister for all active addons, which means all calls to unregister_module will fail.
This was not a visible issue, because reloading that happens immediately after would silently unregister classes already existing, so could only be detected when an addon had gone missing in between.
Will just clear TypeMap after unregistering all addons, see no reason to do it before hand anyway.
This issue was referenced by blender/blender@8f0dc3cef6
Changed status from 'Open' to: 'Resolved'