[Bf-blender-cvs] [adab35b] master: Fix T47529: Selecting paths makes them relative

Campbell Barton noreply at git.blender.org
Mon Feb 22 20:47:18 CET 2016


Commit: adab35ba02476c9b3f77f31b2ac77ebd4c4fdbcf
Author: Campbell Barton
Date:   Tue Feb 23 06:37:01 2016 +1100
Branches: master
https://developer.blender.org/rBadab35ba02476c9b3f77f31b2ac77ebd4c4fdbcf

Fix T47529: Selecting paths makes them relative

When selecting file-paths from the interface, initialize the 'Relative' setting from existing paths.

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

M	source/blender/editors/space_buttons/buttons_ops.c

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

diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index c665a2e..fc1b687 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -219,17 +219,30 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		fbo->is_undo = is_undo;
 		op->customdata = fbo;
 
-		RNA_string_set(op->ptr, path_prop, str);
-		MEM_freeN(str);
-
 		/* normally ED_fileselect_get_params would handle this but we need to because of stupid
 		 * user-prefs exception - campbell */
 		if ((prop_relpath = RNA_struct_find_property(op->ptr, "relative_path"))) {
 			if (!RNA_property_is_set(op->ptr, prop_relpath)) {
+				bool is_relative = (U.flag & USER_RELPATHS) != 0;
+
+				/* while we want to follow the defaults,
+				 * we better not switch existing paths relative/absolute state. */
+				if (str[0]) {
+					is_relative = BLI_path_is_rel(str);
+				}
+
+				if (UNLIKELY(ptr.data == &U)) {
+					is_relative = false;
+				}
+
 				/* annoying exception!, if were dealing with the user prefs, default relative to be off */
-				RNA_property_boolean_set(op->ptr, prop_relpath, U.flag & USER_RELPATHS && (ptr.data != &U));
+				RNA_property_boolean_set(op->ptr, prop_relpath, is_relative);
 			}
 		}
+
+		RNA_string_set(op->ptr, path_prop, str);
+		MEM_freeN(str);
+
 		WM_event_add_fileselect(C, op);
 
 		return OPERATOR_RUNNING_MODAL;




More information about the Bf-blender-cvs mailing list