Fix #147984: "Open Image" button always creates absolute file path

Before [0] this was read from the filepath, however some sequencer
operators only defined a `directory` & `files` and would attempt
to use a non-existent `filepath` property to detect if the path
was relative.

Resolve by making the directory relative as well as the filepath.

Ref !148106

[0]: 7d67113a8a
This commit is contained in:
Campbell Barton
2025-10-15 07:09:59 +00:00
parent d64f7b2f5e
commit 7bc7b7743b

View File

@@ -1597,19 +1597,23 @@ void file_sfile_to_operator_ex(
{
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
PropertyRNA *prop;
char dir[FILE_MAX];
BLI_strncpy(dir, params->dir, FILE_MAX);
BLI_path_slash_ensure(dir, FILE_MAX);
/* XXX, not real length */
if (params->file[0]) {
BLI_path_join(filepath, FILE_MAX, params->dir, params->file);
}
else {
BLI_strncpy(filepath, params->dir, FILE_MAX);
BLI_path_slash_ensure(filepath, FILE_MAX);
BLI_strncpy(filepath, dir, FILE_MAX);
}
if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
if (RNA_property_boolean_get(op->ptr, prop)) {
BLI_path_rel(filepath, BKE_main_blendfile_path(bmain));
BLI_path_rel(dir, BKE_main_blendfile_path(bmain));
}
}
@@ -1623,8 +1627,8 @@ void file_sfile_to_operator_ex(
}
if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
RNA_property_string_get(op->ptr, prop, value);
RNA_property_string_set(op->ptr, prop, params->dir);
if (RNA_property_update_check(prop) && !STREQ(params->dir, value)) {
RNA_property_string_set(op->ptr, prop, dir);
if (RNA_property_update_check(prop) && !STREQ(dir, value)) {
RNA_property_update(C, op->ptr, prop);
}
}