diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-22 22:37:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-22 22:39:34 +0300 |
commit | adab35ba02476c9b3f77f31b2ac77ebd4c4fdbcf (patch) | |
tree | 938ebe52416d0bc67934d59f7322862f10989b49 /source/blender/editors | |
parent | 2a3bd4621b04c6ddb3883f72909ffcec8f788c35 (diff) |
Fix T47529: Selecting paths makes them relative
When selecting file-paths from the interface, initialize the 'Relative' setting from existing paths.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 21 |
1 files changed, 17 insertions, 4 deletions
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; |