[Bf-blender-cvs] [9b602a8020c] master: Preferences: remove temp directory initialization for WIN32

Campbell Barton noreply at git.blender.org
Sat Oct 3 10:52:35 CEST 2020


Commit: 9b602a8020c76c75809291683da1438688b9f8e9
Author: Campbell Barton
Date:   Sat Oct 3 17:51:30 2020 +1000
Branches: master
https://developer.blender.org/rB9b602a8020c76c75809291683da1438688b9f8e9

Preferences: remove temp directory initialization for WIN32

Revert 76b1a27f96ffe1ec8c5351f34bcc2b9733b4483e since there is no
reason windows should behave differently to other platforms.

This was added so Windows users wouldn't see "/tmp/" in the UI.

Since then the default temporary directory is a blank string,
leave blank on all systems as Python script authors may accidentally
use this instead of `bpy.app.tempdir`.

===================================================================

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

===================================================================

diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index 9223a60c8ef..09d74c16bc8 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -59,7 +59,7 @@ bool BKE_appdir_program_python_search(char *fullpath,
                                       const int version_minor);
 
 /* Initialize path to temporary directory. */
-void BKE_tempdir_init(char *userdir);
+void BKE_tempdir_init(const char *userdir);
 
 const char *BKE_tempdir_base(void);
 const char *BKE_tempdir_session(void);
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 2f7b2cc480c..062716feffc 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -881,12 +881,13 @@ void BKE_appdir_app_templates(ListBase *templates)
  *
  * Also make sure the temp dir has a trailing slash
  *
- * \param fullname: The full path to the temporary temp directory
- * \param basename: The full path to the persistent temp directory (may be NULL)
- * \param maxlen: The size of the fullname buffer
- * \param userdir: Directory specified in user preferences
+ * \param fullname: The full path to the temporary temp directory.
+ * \param basename: The full path to the persistent temp directory (may be NULL).
+ * \param maxlen: The size of the \a fullname buffer.
+ * \param userdir: Directory specified in user preferences (may be NULL).
+ * note that by default this is an empty string, only use when non-empty.
  */
-static void where_is_temp(char *fullname, char *basename, const size_t maxlen, char *userdir)
+static void where_is_temp(char *fullname, char *basename, const size_t maxlen, const char *userdir)
 {
   /* Clear existing temp dir, if needed. */
   BKE_tempdir_session_purge();
@@ -930,12 +931,6 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
   else {
     /* add a trailing slash if needed */
     BLI_path_slash_ensure(fullname);
-#ifdef WIN32
-    if (userdir && userdir != fullname) {
-      /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
-      BLI_strncpy(userdir, fullname, maxlen);
-    }
-#endif
   }
 
   /* Now that we have a valid temp dir, add system-generated unique sub-dir. */
@@ -974,10 +969,8 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
  * Sets btempdir_base to userdir if specified and is a valid directory, otherwise
  * chooses a suitable OS-specific temporary directory.
  * Sets btempdir_session to a #mkdtemp generated sub-dir of btempdir_base.
- *
- * \note On Window userdir will be set to the temporary directory!
  */
-void BKE_tempdir_init(char *userdir)
+void BKE_tempdir_init(const char *userdir)
 {
   where_is_temp(btempdir_session, btempdir_base, FILE_MAX, userdir);
 }



More information about the Bf-blender-cvs mailing list