소스 검색

Hopefully fix the preferences finding bug

Joseph Brandenburg 1 개월 전
부모
커밋
835c162de5
3개의 변경된 파일12개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 1
      __init__.py
  2. 1 1
      blender_manifest.toml
  3. 10 6
      preferences.py

+ 1 - 1
__init__.py

@@ -18,7 +18,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=12
-MANTIS_VERSION_SUB=23
+MANTIS_VERSION_SUB=24
 
 classLists = [module.TellClasses() for module in [
  link_nodes_ui,

+ 1 - 1
blender_manifest.toml

@@ -3,7 +3,7 @@ schema_version = "1.0.0"
 # Example of manifest file for a Blender extension
 # Change the values according to your extension
 id = "mantis"
-version = "0.12.23"
+version = "0.12.24"
 name = "Mantis"
 tagline = "Mantis is a rigging nodes toolkit"
 maintainer = "Nodespaghetti <josephbburg@protonmail.com>"

+ 10 - 6
preferences.py

@@ -6,17 +6,21 @@ dir_path = os.path.dirname(os.path.realpath(__file__))
 
 def get_bl_addon_object(raise_error = False):
     from bpy import context
-    try_these_first = ['bl_ext.repos.mantis', 'bl_ext.blender_modules_enabled.mantis',
-        'bl_ext.nodes_tools.mantis']
+    try_these_first = ['bl_ext.nodes_tools.mantis', 
+        'bl_ext.repos.mantis', 'bl_ext.blender_modules_enabled.mantis',]
     for mantis_key in try_these_first:
         bl_mantis_addon = context.preferences.addons.get(mantis_key)
-        if bl_mantis_addon: break
+        if bl_mantis_addon is not None: # chekc the addon AND the prefs
+            if bl_mantis_addon.preferences is not None: break
+            # the prefs will be None if the addon is disabled.
     else:
         for k in context.preferences.addons.keys():
-            if "mantis" in k:
+            if k.endswith("mantis"):
                 bl_mantis_addon = context.preferences.addons[k]
-                prWhite(f"Unexpected addon preferences key: {k}")
-                break
+                print(f"Unexpected addon preferences key: {k}")
+                if bl_mantis_addon is not None:
+                    if bl_mantis_addon.preferences is not None:
+                        break
     raise_error = True
     if bl_mantis_addon is None:
         if raise_error==True: