@@ -88,23 +88,44 @@ def reload_image(filepath, image_name):
8888 image .preview_ensure ()
8989 image .gl_load ()
9090
91- if "use_custom_mouse_image" not in prefs :
92- return
93- if not prefs ["use_custom_mouse_image" ]:
94- return
95-
96- if "custom_mouse_image_base" in prefs :
97- reload_image (prefs ["custom_mouse_image_base" ],
98- CUSTOM_MOUSE_IMG_BASE_NAME )
99- if "custom_mouse_image_left_mouse" in prefs :
100- reload_image (prefs ["custom_mouse_image_left_mouse" ],
101- CUSTOM_MOUSE_IMG_LMOUSE_NAME )
102- if "custom_mouse_image_right_mouse" in prefs :
103- reload_image (prefs ["custom_mouse_image_right_mouse" ],
104- CUSTOM_MOUSE_IMG_RMOUSE_NAME )
105- if "custom_mouse_image_middle_mouse" in prefs :
106- reload_image (prefs ["custom_mouse_image_middle_mouse" ],
107- CUSTOM_MOUSE_IMG_MMOUSE_NAME )
91+ # From Blender 5.0, the specification of bpy.types.AddonPreferences
92+ # is changed. This change does not allow dict based accesses.
93+ if compat .check_version (5 , 0 , 0 ) >= 0 :
94+ if "use_custom_mouse_image" not in dir (prefs ):
95+ return
96+ if not prefs .use_custom_mouse_image :
97+ return
98+
99+ if "custom_mouse_image_base" in dir (prefs ):
100+ reload_image (prefs .custom_mouse_image_base ,
101+ CUSTOM_MOUSE_IMG_BASE_NAME )
102+ if "custom_mouse_image_left_mouse" in dir (prefs ):
103+ reload_image (prefs .custom_mouse_image_left_mouse ,
104+ CUSTOM_MOUSE_IMG_LMOUSE_NAME )
105+ if "custom_mouse_image_right_mouse" in dir (prefs ):
106+ reload_image (prefs .custom_mouse_image_right_mouse ,
107+ CUSTOM_MOUSE_IMG_RMOUSE_NAME )
108+ if "custom_mouse_image_middle_mouse" in dir (prefs ):
109+ reload_image (prefs .custom_mouse_image_middle_mouse ,
110+ CUSTOM_MOUSE_IMG_MMOUSE_NAME )
111+ else :
112+ if "use_custom_mouse_image" not in prefs :
113+ return
114+ if not prefs ["use_custom_mouse_image" ]:
115+ return
116+
117+ if "custom_mouse_image_base" in prefs :
118+ reload_image (prefs ["custom_mouse_image_base" ],
119+ CUSTOM_MOUSE_IMG_BASE_NAME )
120+ if "custom_mouse_image_left_mouse" in prefs :
121+ reload_image (prefs ["custom_mouse_image_left_mouse" ],
122+ CUSTOM_MOUSE_IMG_LMOUSE_NAME )
123+ if "custom_mouse_image_right_mouse" in prefs :
124+ reload_image (prefs ["custom_mouse_image_right_mouse" ],
125+ CUSTOM_MOUSE_IMG_RMOUSE_NAME )
126+ if "custom_mouse_image_middle_mouse" in prefs :
127+ reload_image (prefs ["custom_mouse_image_middle_mouse" ],
128+ CUSTOM_MOUSE_IMG_MMOUSE_NAME )
108129
109130 ensure_custom_mouse_images ()
110131
0 commit comments