minor changes to registration before committing addons fixes
This commit is contained in:
@@ -29,7 +29,7 @@ import sys as _sys
|
||||
|
||||
from _bpy import blend_paths
|
||||
from _bpy import script_paths as _bpy_script_paths
|
||||
from _bpy import LoadModule, UnloadModule
|
||||
from _bpy import _load_module, _unload_module
|
||||
|
||||
|
||||
def _test_import(module_name, loaded_modules):
|
||||
@@ -113,7 +113,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
||||
original_modules = _sys.modules.values()
|
||||
|
||||
def unload_module(mod):
|
||||
UnloadModule(mod.__name__)
|
||||
_unload_module(mod.__name__)
|
||||
unregister = getattr(mod, "unregister", None)
|
||||
if unregister:
|
||||
try:
|
||||
@@ -147,7 +147,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
||||
mod = test_reload(mod)
|
||||
|
||||
if mod:
|
||||
LoadModule(mod.__name__, reload_scripts)
|
||||
_load_module(mod.__name__, reload_scripts)
|
||||
register = getattr(mod, "register", None)
|
||||
if register:
|
||||
try:
|
||||
|
||||
@@ -551,29 +551,32 @@ PropertiesMap = {}
|
||||
# registers moduals instantly.
|
||||
_register_immediate = True
|
||||
|
||||
def UnloadModule(module):
|
||||
for t in TypeMap.setdefault(module, ()):
|
||||
def _unload_module(module):
|
||||
for t in TypeMap.get(module, ()):
|
||||
bpy_types.unregister(t)
|
||||
|
||||
del TypeMap[module]
|
||||
|
||||
for t in PropertiesMap.setdefault(module, ()):
|
||||
if module in TypeMap:
|
||||
del TypeMap[module]
|
||||
|
||||
|
||||
for t in PropertiesMap.get(module, ()):
|
||||
bpy_types.unregister(t)
|
||||
|
||||
del PropertiesMap[module]
|
||||
|
||||
def LoadModule(module, force=False):
|
||||
if module in PropertiesMap:
|
||||
del PropertiesMap[module]
|
||||
|
||||
def _load_module(module, force=False):
|
||||
for t in TypeMap.get(module, ()):
|
||||
bpy_types.register(t)
|
||||
|
||||
_bpy.LoadModule = LoadModule
|
||||
_bpy.UnloadModule = UnloadModule
|
||||
_bpy._load_module = _load_module
|
||||
_bpy._unload_module = _unload_module
|
||||
|
||||
class RNAMeta(type):
|
||||
@classmethod
|
||||
def _register_immediate(cls):
|
||||
return _register_immediate
|
||||
|
||||
|
||||
def __new__(cls, name, bases, classdict, **args):
|
||||
result = type.__new__(cls, name, bases, classdict)
|
||||
if bases and bases[0] != StructRNA:
|
||||
@@ -589,7 +592,7 @@ class RNAMeta(type):
|
||||
# first part of packages only
|
||||
if "." in module:
|
||||
module = module[:module.index(".")]
|
||||
|
||||
|
||||
ClassMap.setdefault(module, []).append(result)
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user