Fix #125607: Double imports due to duplicate IO paths
`paths_from_operator_properties` can return paths for both the explicit
operator `filepath` property as well as the `directory` content.
16129d6a attempted to fix this, but fails because one instance of a path
can be absolute and the other negative.
This patch makes sure to only compare absolute paths. Comparison uses
a separate list so that the final output can still mix absolute and
relative paths, but should only include each path once.
Pull Request: https://projects.blender.org/blender/blender/pulls/125608
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_main.hh"
|
||||
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
@@ -74,10 +75,17 @@ Vector<std::string> paths_from_operator_properties(PointerRNA *ptr)
|
||||
{
|
||||
Vector<std::string> paths;
|
||||
PropertyRNA *directory_prop = RNA_struct_find_property(ptr, "directory");
|
||||
PropertyRNA *relative_path_prop = RNA_struct_find_property(ptr, "relative_path");
|
||||
const bool is_relative_path = relative_path_prop ?
|
||||
RNA_property_boolean_get(ptr, relative_path_prop) :
|
||||
false;
|
||||
if (RNA_property_is_set(ptr, directory_prop)) {
|
||||
char directory[FILE_MAX], name[FILE_MAX];
|
||||
|
||||
RNA_string_get(ptr, "directory", directory);
|
||||
if (is_relative_path && !BLI_path_is_rel(directory)) {
|
||||
BLI_path_rel(directory, BKE_main_blendfile_path_from_global());
|
||||
}
|
||||
|
||||
PropertyRNA *files_prop = RNA_struct_find_collection_property_check(
|
||||
*ptr, "files", &RNA_OperatorFileListElement);
|
||||
@@ -96,6 +104,9 @@ Vector<std::string> paths_from_operator_properties(PointerRNA *ptr)
|
||||
if (filepath_prop && RNA_property_is_set(ptr, filepath_prop)) {
|
||||
char filepath[FILE_MAX];
|
||||
RNA_string_get(ptr, "filepath", filepath);
|
||||
if (is_relative_path && !BLI_path_is_rel(filepath)) {
|
||||
BLI_path_rel(filepath, BKE_main_blendfile_path_from_global());
|
||||
}
|
||||
paths.append_non_duplicates(filepath);
|
||||
}
|
||||
return paths;
|
||||
|
||||
Reference in New Issue
Block a user