Fix T47529: Selecting paths makes them relative
When selecting file-paths from the interface, initialize the 'Relative' setting from existing paths.
This commit is contained in:
parent
2a3bd4621b
commit
adab35ba02
Notes:
blender-bot
2023-02-14 19:49:52 +01:00
Referenced by issue blender/blender-addons#47529, String property with sub_type =file_path gives wrong path
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue