StudioLight: remove caches when removing studiolight
Cache files were not deleted and when uploading a new file with the same name resulted in using the old cache file.
This commit is contained in:
parent
e402c36388
commit
0427eca2a6
|
@ -2478,16 +2478,20 @@ class WM_OT_studiolight_uninstall(Operator):
|
|||
bl_label = "Uninstall Studio Light"
|
||||
index = bpy.props.IntProperty()
|
||||
|
||||
def _remove_path(self, path):
|
||||
if path.exists():
|
||||
path.unlink()
|
||||
|
||||
def execute(self, context):
|
||||
import pathlib
|
||||
userpref = context.user_preferences
|
||||
for studio_light in userpref.studio_lights:
|
||||
if studio_light.index == self.index:
|
||||
path = pathlib.Path(studio_light.path)
|
||||
if path.exists():
|
||||
path.unlink()
|
||||
userpref.studio_lights_refresh()
|
||||
return {'FINISHED'}
|
||||
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))
|
||||
userpref.studio_lights_refresh()
|
||||
return {'FINISHED'}
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
|
|
|
@ -692,6 +692,32 @@ static int rna_UserDef_studiolight_path_length(PointerRNA *ptr)
|
|||
return strlen(sl->path);
|
||||
}
|
||||
|
||||
/* StudioLight.path_irr_cache */
|
||||
static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
StudioLight *sl = (StudioLight *)ptr->data;
|
||||
BLI_strncpy(value, sl->path_irr_cache, FILE_MAX);
|
||||
}
|
||||
|
||||
static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr)
|
||||
{
|
||||
StudioLight *sl = (StudioLight *)ptr->data;
|
||||
return strlen(sl->path_irr_cache);
|
||||
}
|
||||
|
||||
/* StudioLight.path_sh_cache */
|
||||
static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
StudioLight *sl = (StudioLight *)ptr->data;
|
||||
BLI_strncpy(value, sl->path_sh_cache, FILE_MAX);
|
||||
}
|
||||
|
||||
static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr)
|
||||
{
|
||||
StudioLight *sl = (StudioLight *)ptr->data;
|
||||
return strlen(sl->path_sh_cache);
|
||||
}
|
||||
|
||||
/* StudioLight.index */
|
||||
static int rna_UserDef_studiolight_index_get(PointerRNA *ptr)
|
||||
{
|
||||
|
@ -3270,6 +3296,16 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Path", "");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "path_irr_cache", PROP_STRING, PROP_DIRPATH);
|
||||
RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_irr_cache_get", "rna_UserDef_studiolight_path_irr_cache_length", NULL);
|
||||
RNA_def_property_ui_text(prop, "Irradiance Cache Path", "Path where the irradiance cache is stored");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "path_sh_cache", PROP_STRING, PROP_DIRPATH);
|
||||
RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_sh_cache_get", "rna_UserDef_studiolight_path_sh_cache_length", NULL);
|
||||
RNA_def_property_ui_text(prop, "SH Cache Path", "Path where the spherical harmonics cache is stored");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
RNA_define_verify_sdna(true);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue