Browse Source

Another hack at finding the prefs

Joseph Brandenburg 1 month ago
parent
commit
a8d384f60e
4 changed files with 12 additions and 7 deletions
  1. 1 1
      __init__.py
  2. 1 1
      blender_manifest.toml
  3. 9 4
      preferences.py
  4. 1 1
      socket_definitions.py

+ 1 - 1
__init__.py

@@ -18,7 +18,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=12
-MANTIS_VERSION_SUB=24
+MANTIS_VERSION_SUB=25
 
 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.24"
+version = "0.12.25"
 name = "Mantis"
 tagline = "Mantis is a rigging nodes toolkit"
 maintainer = "Nodespaghetti <josephbburg@protonmail.com>"

+ 9 - 4
preferences.py

@@ -8,21 +8,26 @@ def get_bl_addon_object(raise_error = False):
     from bpy import context
     try_these_first = ['bl_ext.nodes_tools.mantis', 
         'bl_ext.repos.mantis', 'bl_ext.blender_modules_enabled.mantis',]
+    print (context.preferences.addons.keys())
     for mantis_key in try_these_first:
         bl_mantis_addon = context.preferences.addons.get(mantis_key)
         if bl_mantis_addon is not None: # chekc the addon AND the prefs
-            if bl_mantis_addon.preferences is not None: break
+            print (f"Found Mantis: {mantis_key}")
+            if bl_mantis_addon.preferences is not None:
+                print (f"Found Mantis preferences: {mantis_key}")
+                break
             # the prefs will be None if the addon is disabled.
     else:
         for k in context.preferences.addons.keys():
             if k.endswith("mantis"):
                 bl_mantis_addon = context.preferences.addons[k]
-                print(f"Unexpected addon preferences key: {k}")
                 if bl_mantis_addon is not None:
                     if bl_mantis_addon.preferences is not None:
+                        print(f"Unexpected addon preferences key: {k}")
                         break
-    raise_error = True
-    if bl_mantis_addon is None:
+        else:
+            print("FAILED TO FIND MANTIS.")
+    if bl_mantis_addon is None or bl_mantis_addon.preferences is None:
         if raise_error==True:
             raise RuntimeError("Mantis Preferences not found. This is a bug."
                             " Please report it on gitlab.")

+ 1 - 1
socket_definitions.py

@@ -1441,7 +1441,7 @@ def get_widget_library_items(self, context):
     default_missing_value = ('MISSING', f'MISSING: {prev_name}', self.previous_value, 'ERROR', self.previous_index)
     return_value = [default_missing_value]
     widget_names={}
-    if bl_mantis_addon:
+    if bl_mantis_addon and bl_mantis_addon.preferences:
         widgets_path = bl_mantis_addon.preferences.WidgetsLibraryFolder
         from os import walk as os_walk
         for path_root, dirs, files, in os_walk(widgets_path):