Tweaks to previous commit
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Nov 2013 08:46:36 +0000 (14:46 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Nov 2013 08:46:36 +0000 (14:46 +0600)
- Use simplified expression for checking whether Cycles present or not
- Need to check for Cycles in unregister() as well

TODO: Keymap unregister still gives issues, but that's nothing to do
      with Cycles.

scene_amaranth_toolset.py

index b590f99..d4f46e5 100644 (file)
@@ -1086,7 +1086,7 @@ kmi_defs = (
 
 def register():
     import sys
-    have_cycles = True if "_cycles" in sys.modules else False
+    have_cycles = ("_cycles" in sys.modules)
 
     bpy.utils.register_class(AmaranthToolsetPreferences)
 
@@ -1172,6 +1172,8 @@ def register():
             addon_keymaps.append((km, kmi))
 
 def unregister():
+    import sys
+    have_cycles = ("_cycles" in sys.modules)
 
     bpy.utils.unregister_class(AmaranthToolsetPreferences)
 
@@ -1194,13 +1196,15 @@ def unregister():
     bpy.types.NODE_HT_header.remove(node_templates_pulldown)
     bpy.types.NODE_HT_header.remove(node_stats)
 
-    bpy.types.CyclesMaterial_PT_settings.remove(material_cycles_settings_extra)
-    bpy.types.CyclesRender_PT_sampling.remove(render_cycles_scene_samples)
+    if have_cycles:
+        bpy.types.CyclesMaterial_PT_settings.remove(material_cycles_settings_extra)
+        bpy.types.CyclesRender_PT_sampling.remove(render_cycles_scene_samples)
 
     bpy.types.FILEBROWSER_HT_header.remove(button_directory_current_blend)
 
     bpy.types.SCENE_PT_simplify.remove(unsimplify_ui)
-    bpy.types.CyclesScene_PT_simplify.remove(unsimplify_ui)
+    if have_cycles:
+        bpy.types.CyclesScene_PT_simplify.remove(unsimplify_ui)
 
     bpy.types.PARTICLE_PT_render.remove(particles_material_info)