Fix T58104: Duplicated previews for Matcaps/HDRIs in portable installs
authorPhilipp Oeser <info@graphics-engineer.com>
Mon, 3 Dec 2018 19:55:36 +0000 (20:55 +0100)
committerPhilipp Oeser <info@graphics-engineer.com>
Wed, 5 Dec 2018 13:53:44 +0000 (14:53 +0100)
Reviewers: brecht

Maniphest Tasks: T58104

Differential Revision: https://developer.blender.org/D4028

source/blender/blenkernel/BKE_appdir.h
source/blender/blenkernel/intern/appdir.c
source/blender/blenkernel/intern/studiolight.c

index 6162c7b6bf643767b5addad2a816f39dd932ebf5..8496c56a9c746b5950b1aa2442eb289d58b8562c 100644 (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);
index 2848c2455531ed055cdfd8e6394c6f55062ab872..3643bf54e48321721334b470e71cdc92723d9d32 100644 (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';
index 5196ae50bab4f520a8a0359f4e71963129f241c0..bd8061a2d8e55cadfb39db81a1438efae7548e3d 100644 (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);