2 Commits 75f30e4640 ... 317badc742

Autore SHA1 Messaggio Data
  Joseph Brandenburg 317badc742 Fix 5.0 Display Update Error 1 settimana fa
  Joseph Brandenburg f2fd79a23f small fix for relink socket map 1 mese fa
1 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 14 3
      utilities.py

+ 14 - 3
utilities.py

@@ -145,11 +145,18 @@ def get_socket_maps(node, force=False):
                     keep_sockets.append(other_socket)
                 map[sock.identifier]= keep_sockets
             elif hasattr(sock, "default_value"):
-                if sock.bl_idname == "EnumCurveSocket" and sock.get("default_value") is None:
+                # NOTE: Blender 5.0 and greater have removed sock.get("attr").
+                #    I hope getattr does exactly the same thing, but I worry about changes.
+                #    If I remember correctly, I used this particular syntax because the behaviour
+                #    of sock.get("attr") vs. getattr(sock, "attr") was affected by the file load time
+                #    and the former could retrieve the data while the latter lost it.
+                #    However, since, IIRC, this only happened in the first case with curves
+                #    I feel confident it will work everywhere else.
+                if sock.bl_idname == "EnumCurveSocket" and getattr(sock, "default_value") is None:
                     # HACK I need to add this special case because during file-load,
                     #  this value is None and should not be altered until it is set once.
                     continue
-                elif "Enum" in sock.bl_idname and isinstance(sock.get("default_value"), int):
+                elif "Enum" in sock.bl_idname and isinstance(getattr(sock, "default_value"), int):
                     continue # for string enum properties that have not yet initialized (at startup)
                 elif (val := sock.default_value) is not None:
                     pass
@@ -313,7 +320,11 @@ def relink_socket_map_add_socket(node, socket_collection, item,  in_out=None,):
             if val_type is Vector: default_value = item.default_vector
             if val_type is str: default_value = item.default_string
             if val_type is bpy_prop_array: default_value = item.default_bool_vector
-            s.default_value = default_value
+            if not s.is_property_readonly("default_value"):
+                s.default_value = default_value
+            else: # TODO: make this work with color sets.
+                raise Warning("WARN: Not yet implemented: default values for color sets.")
+                
 
     if read_schema_type(item) == 'Array': s.display_shape = 'SQUARE_DOT'
     elif node.bl_idname in ['MantisSchemaGroup'] and read_schema_type(item) == 'Constant':