Fix T58104: Duplicated previews for Matcaps/HDRIs in portable installs

Reviewers: brecht

Maniphest Tasks: T58104

Differential Revision: https://developer.blender.org/D4028
This commit is contained in:
Philipp Oeser 2018-12-03 20:55:36 +01:00
parent fb3f1a3567
commit 378e5232e8
Notes: blender-bot 2023-02-14 11:01:33 +01:00
Referenced by issue #58104, Duplicated previews for Matcaps and HDRI's if config folder is present
3 changed files with 15 additions and 5 deletions

View File

@ -34,6 +34,7 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *subfolder);
const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, const bool do_check);
bool BKE_appdir_app_is_portable_install(void);
bool BKE_appdir_app_template_any(void);
bool BKE_appdir_app_template_id_search(const char *app_template, char *path, size_t path_len);
void BKE_appdir_app_templates(struct ListBase *templates);

View File

@ -229,7 +229,7 @@ static bool get_path_local(
* Is this an install with user files kept together with the Blender executable and its
* installation files.
*/
static bool is_portable_install(void)
bool BKE_appdir_app_is_portable_install(void)
{
/* detect portable install by the existence of config folder */
const int ver = BLENDER_VERSION;
@ -289,7 +289,7 @@ static bool get_path_user(
const char *user_base_path;
/* for portable install, user path is always local */
if (is_portable_install()) {
if (BKE_appdir_app_is_portable_install()) {
return get_path_local(targetpath, targetpath_len, folder_name, subfolder_name, ver);
}
user_path[0] = '\0';

View File

@ -1219,13 +1219,22 @@ void BKE_studiolight_init(void)
BLI_addtail(&studiolights, sl);
/* go over the preset folder and add a studiolight for every image with its path */
/* for portable installs (where USER and SYSTEM paths are the same), only go over LOCAL datafiles once */
/* Also reserve icon space for it. */
if (!BKE_appdir_app_is_portable_install()) {
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
STUDIOLIGHT_LIGHTS_FOLDER,
STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_USER_DEFINED);
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
STUDIOLIGHT_WORLD_FOLDER,
STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_USER_DEFINED);
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
STUDIOLIGHT_MATCAP_FOLDER,
STUDIOLIGHT_TYPE_MATCAP | STUDIOLIGHT_USER_DEFINED);
}
studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_LIGHTS_FOLDER, STUDIOLIGHT_TYPE_STUDIO);
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_LIGHTS_FOLDER, STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_USER_DEFINED);
studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_TYPE_WORLD);
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_USER_DEFINED);
studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_TYPE_MATCAP);
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_TYPE_MATCAP | STUDIOLIGHT_USER_DEFINED);
/* sort studio lights on filename. */
BLI_listbase_sort(&studiolights, studiolight_cmp);