Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-02 08:20:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-02 08:20:41 +0400
commit55e64f0ba4f43535a163090ddf6a1715de0a6fa4 (patch)
treef278c6f30429c9cd41ed554ca11ead5dc0ccc86c /release/scripts/modules/bpy_types.py
parent3d81ee3e4aaa5f146c5fb36cef8ad3ec5a81100f (diff)
minor changes to Martni's commit 30961
- removed the immediate option from C/api and now store in python only, when python loads modules it sets it to False. - unloading a module would clear the entire TypeMap for all modules, only remove the module types that is being unloaded. - added some checks for bad class registering, report errors rather then crashing.
Diffstat (limited to 'release/scripts/modules/bpy_types.py')
-rw-r--r--release/scripts/modules/bpy_types.py42
1 files changed, 22 insertions, 20 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 7e7b7f128ab..a5161768bea 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -546,20 +546,24 @@ TypeMap = {}
# and unregistered on unload
PropertiesMap = {}
+# Using our own loading function we set this to false
+# so when running a script directly in the text editor
+# registers moduals instantly.
+_register_immediate = True
+
def UnloadModule(module):
- global TypeMap, PropertiesMap
- for t in TypeMap.get(module, []):
+ for t in TypeMap.setdefault(module, ()):
bpy_types.unregister(t)
- TypeMap = {}
+ del TypeMap[module]
- for t in PropertiesMap.get(module, []):
+ for t in PropertiesMap.setdefault(module, ()):
bpy_types.unregister(t)
- PropertiesMap = {}
-
+ del PropertiesMap[module]
+
def LoadModule(module, force=False):
- for t in TypeMap.get(module, []):
+ for t in TypeMap.get(module, ()):
bpy_types.register(t)
_bpy.LoadModule = LoadModule
@@ -567,35 +571,33 @@ _bpy.UnloadModule = UnloadModule
class RNAMeta(type):
@classmethod
- def _immediate(cls):
- return bpy_types.immediate();
-
+ 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:
module = result.__module__
-
+
ClassMap = TypeMap
-
+
# Register right away if needed
- if cls._immediate():
+ if cls._register_immediate():
bpy_types.register(result)
ClassMap = PropertiesMap
# first part of packages only
if "." in module:
module = module[:module.index(".")]
-
- if not module in ClassMap:
- ClassMap[module] = []
-
- ClassMap[module].append(result)
+
+ ClassMap.setdefault(module, []).append(result)
+
return result
class RNAMetaRegister(RNAMeta):
@classmethod
- def _immediate(cls):
- return True;
+ def _register_immediate(cls):
+ return True
class OrderedMeta(RNAMeta):