From adab35ba02476c9b3f77f31b2ac77ebd4c4fdbcf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Feb 2016 06:37:01 +1100 Subject: Fix T47529: Selecting paths makes them relative When selecting file-paths from the interface, initialize the 'Relative' setting from existing paths. --- source/blender/editors/space_buttons/buttons_ops.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_buttons') diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index c665a2e6cbe..fc1b6877f5e 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; -- cgit v1.2.3