Fix T39450: CTest 'script_load_addons' fails
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 21 Jul 2014 22:26:17 +0000 (00:26 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 21 Jul 2014 22:44:01 +0000 (00:44 +0200)
Various minor fixes/cleanup to make 'script_load_addons' test work again.

Note about Amaranth changes: cycles check has to be live in some cases (global
variable is set only once, on first import, cycles might be disabled later and then
unregister would fail).

io_import_lipSync_Importer.py
mesh_face_info_select.py
object_booleans.py
scene_amaranth_toolset.py

index 495fb04..32bac9a 100644 (file)
@@ -473,7 +473,7 @@ def register():
 
 def unregister():
     bpy.utils.unregister_module(__name__)
-    del bpy.context.scene.regMenuTypes
+    del bpy.types.Scene.regMenuTypes
 
     clear_properties()
 
index db96b42..63966a3 100644 (file)
@@ -37,7 +37,7 @@ bl_info = {
 import bpy
 from bpy.props import EnumProperty
 
-class DATA_OP_facetype_select(bpy.types.Operator):
+class DATA_OT_facetype_select(bpy.types.Operator):
     """Select all faces of a certain type"""
     bl_idname = "data.facetype_select"
     bl_label = "Select by face type"
@@ -71,7 +71,6 @@ class DATA_OP_facetype_select(bpy.types.Operator):
 class DATA_PT_info_panel(bpy.types.Panel):
     """Creates a face info / select panel in the Object properties window"""
     bl_label = "Face info / select"
-    bl_idname = "DATA_PT_face_info"
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
     bl_context = "data"
@@ -114,12 +113,12 @@ class DATA_PT_info_panel(bpy.types.Panel):
 
 def register():
     bpy.utils.register_class(DATA_PT_info_panel)
-    bpy.utils.register_class(DATA_OP_facetype_select)
+    bpy.utils.register_class(DATA_OT_facetype_select)
 
 
 def unregister():
     bpy.utils.unregister_class(DATA_PT_info_panel)
-    bpy.utils.unregister_class(DATA_OP_facetype_select)
+    bpy.utils.unregister_class(DATA_OT_facetype_select)
 
 
 if __name__ == "__main__":
index b55a71a..9f66912 100644 (file)
@@ -139,10 +139,10 @@ def unregister():
 
 
     # remove keymaps when add-on is deactivated
-    wm = bpy.context.window_manager
-    for km in addon_keymaps:
-        wm.keyconfigs.addon.keymaps.remove(km)
-    del addon_keymaps[:]
+    #wm = bpy.context.window_manager
+    #for km in addon_keymaps:
+        #wm.keyconfigs.addon.keymaps.remove(km)
+    #del addon_keymaps[:]
 
 if __name__ == "__main__":
     register()
\ No newline at end of file
index 431e18f..cf792bf 100755 (executable)
@@ -40,8 +40,17 @@ from bpy.app.handlers import persistent
 from bl_operators.presets import AddPresetBase
 
 # Addon wide, we need to know if cycles is available
-global cycles_exists
-cycles_exists = 'cycles' in dir(bpy.types.Scene)
+cycles_exists = False
+
+
+def check_cycles_exists():
+    global cycles_exists
+    cycles_exists = ('cycles' in dir(bpy.types.Scene))
+    return cycles_exists
+
+
+check_cycles_exists()
+
 
 # Preferences
 class AmaranthToolsetPreferences(AddonPreferences):
@@ -177,7 +186,7 @@ def init_properties():
 
     # Scene Debug
     # Cycles Node Types
-    if cycles_exists:
+    if check_cycles_exists():
         cycles_shader_node_types = [
             ("BSDF_DIFFUSE", "Diffuse BSDF", "", 0),
             ("BSDF_GLOSSY", "Glossy BSDF", "", 1),
@@ -3053,7 +3062,7 @@ def register():
     bpy.types.NODE_HT_header.append(node_shader_extra)
     bpy.types.NODE_PT_active_node_properties.append(ui_node_normal_values)
 
-    if cycles_exists:
+    if check_cycles_exists():
         bpy.types.CyclesRender_PT_sampling.append(render_cycles_scene_samples)
         bpy.types.CyclesScene_PT_simplify.append(unsimplify_ui)
 
@@ -3159,7 +3168,7 @@ def unregister():
     bpy.types.NODE_HT_header.remove(node_shader_extra)
     bpy.types.NODE_PT_active_node_properties.remove(ui_node_normal_values)
 
-    if cycles_exists:
+    if check_cycles_exists():
         bpy.types.CyclesRender_PT_sampling.remove(render_cycles_scene_samples)
         bpy.types.CyclesScene_PT_simplify.remove(unsimplify_ui)