Fix Python error removing studio lights in user preferences.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 17 Jul 2018 12:21:16 +0000 (14:21 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 17 Jul 2018 12:59:07 +0000 (14:59 +0200)
release/scripts/startup/bl_operators/wm.py
source/blender/makesrna/intern/rna_userdef.c

index cfbc96696d6029f9f58f72b3709566fe94800901..3f0cdfa606b656e485b8ae8418c7c899f797177c 100644 (file)
@@ -2499,9 +2499,12 @@ class WM_OT_studiolight_uninstall(Operator):
         userpref = context.user_preferences
         for studio_light in userpref.studio_lights:
             if studio_light.index == self.index:
-                self._remove_path(pathlib.Path(studio_light.path))
-                self._remove_path(pathlib.Path(studio_light.path_irr_cache))
-                self._remove_path(pathlib.Path(studio_light.path_sh_cache))
+                if len(studio_light.path) > 0:
+                    self._remove_path(pathlib.Path(studio_light.path))
+                if len(studio_light.path_irr_cache) > 0:
+                    self._remove_path(pathlib.Path(studio_light.path_irr_cache))
+                if len(studio_light.path_sh_cache) > 0:
+                    self._remove_path(pathlib.Path(studio_light.path_sh_cache))
                 userpref.studio_lights.remove(studio_light)
                 return {'FINISHED'}
         return {'CANCELLED'}
index 5557afdb33f576c69eddf23be338b72268a1bd4d..a54462e6b3e56f9d1fcf700191d8d1598346a0b1 100644 (file)
@@ -683,7 +683,9 @@ static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *va
        if (sl->path_irr_cache) {
                BLI_strncpy(value, sl->path_irr_cache, FILE_MAX);
        }
-       value[0] = 0x00;
+       else {
+               value[0] = '\0';
+       }
 }
 
 static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr)
@@ -702,7 +704,9 @@ static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *val
        if (sl->path_sh_cache) {
                BLI_strncpy(value, sl->path_sh_cache, FILE_MAX);
        }
-       value[0] = 0x00;
+       else {
+               value[0] = '\0';
+       }
 }
 
 static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr)