[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50966] trunk/blender/intern/tools/ bpy_introspect_ui.py: small improvement to bpy_introspect_ui, only define runtime modules & vars before calling draw(), helps find bad API use.

Campbell Barton ideasman42 at gmail.com
Mon Oct 1 04:11:21 CEST 2012


Revision: 50966
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50966
Author:   campbellbarton
Date:     2012-10-01 02:11:19 +0000 (Mon, 01 Oct 2012)
Log Message:
-----------
small improvement to bpy_introspect_ui, only define runtime modules & vars before calling draw(), helps find bad API use.

Modified Paths:
--------------
    trunk/blender/intern/tools/bpy_introspect_ui.py

Modified: trunk/blender/intern/tools/bpy_introspect_ui.py
===================================================================
--- trunk/blender/intern/tools/bpy_introspect_ui.py	2012-10-01 02:04:06 UTC (rev 50965)
+++ trunk/blender/intern/tools/bpy_introspect_ui.py	2012-10-01 02:11:19 UTC (rev 50966)
@@ -243,18 +243,35 @@
     bpy.types.Scene.EnumProperty = NewAttr("bpy.types.Scene.EnumProperty", "EnumProperty")
     bpy.types.Scene.StringProperty = NewAttr("bpy.types.Scene.StringProperty", "StringProperty")
 
+    bpy.props = module_add("bpy.props")
+    bpy.props.StringProperty = dict
+    bpy.props.BoolProperty = dict
+    bpy.props.IntProperty = dict
+    bpy.props.EnumProperty = dict
+
+
+def fake_helper():
+
+    class PropertyPanel():
+        pass
+
+    rna_prop_ui = module_add("rna_prop_ui")
+    rna_prop_ui.PropertyPanel = PropertyPanel
+    rna_prop_ui.draw = NewAttr("rna_prop_ui.draw", "draw")
+
+    rigify = module_add("rigify")
+    rigify.get_submodule_types = lambda: []
+
+
+def fake_runtime():
+    """Only call this before `draw()` functions."""
+
     # Misc Subclasses
     bpy.types.EffectSequence = type("EffectSequence", (), {})
 
     # Operator Subclases
     bpy.types.WM_OT_doc_view = type("WM_OT_doc_view", (), {"_prefix": ""})
 
-    bpy.props = module_add("bpy.props")
-    bpy.props.StringProperty = dict
-    bpy.props.BoolProperty = dict
-    bpy.props.IntProperty = dict
-    bpy.props.EnumProperty = dict
-
     bpy.data = module_add("bpy.data")
     bpy.data.scenes = ()
     bpy.data.speakers = ()
@@ -274,7 +291,7 @@
     bpy.data.particles = ()
 
     bpy.data.file_is_saved = True
-
+    
     bpy.utils = module_add("bpy.utils")
     bpy.utils.smpte_from_frame = lambda f: ""
     bpy.utils.script_paths = lambda f: []
@@ -298,22 +315,10 @@
     addon_utils.error_duplicates = ()
     addon_utils.error_encoding = ()
 
-
-def fake_helper():
-
-    class PropertyPanel():
-        pass
-
-    rna_prop_ui = module_add("rna_prop_ui")
-    rna_prop_ui.PropertyPanel = PropertyPanel
-    rna_prop_ui.draw = NewAttr("rna_prop_ui.draw", "draw")
-
-    rigify = module_add("rigify")
-    rigify.get_submodule_types = lambda: []
-
-
 fake_main()
 fake_helper()
+# fake_runtime()  # call after initial import so we can catch
+#                 # bad use of modules outside of draw() functions.
 
 import bpy
 
@@ -355,6 +360,9 @@
             for cls in classes:
                 setattr(bpy.types, cls.__name__, cls)
 
+
+    fake_runtime()
+
     # print("running...")
     print("<ui>")
     for f in sorted(os.listdir(scripts_dir)):




More information about the Bf-blender-cvs mailing list