mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix regression breaking Into/Convert node type coercion (#3681)
This commit is contained in:
@@ -648,7 +648,7 @@ impl NodeNetworkInterface {
|
||||
|
||||
let export_name = if !export_name.is_empty() {
|
||||
export_name
|
||||
} else if let Some(export_type_name) = input_type.compiled_nested_type().map(|nested| nested.to_string()) {
|
||||
} else if let Some(export_type_name) = input_type.compiled_nested_type().map(ToString::to_string) {
|
||||
export_type_name
|
||||
} else {
|
||||
format!("Export #{}", export_index)
|
||||
@@ -658,12 +658,19 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
};
|
||||
|
||||
let valid_types = self.potential_valid_input_types(input_connector, network_path).iter().map(ToString::to_string).collect::<Vec<_>>();
|
||||
let valid_types = {
|
||||
// Dedupe while preserving order
|
||||
let mut found = HashSet::new();
|
||||
valid_types.into_iter().filter(|s| found.insert(s.clone())).collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
Some(FrontendGraphInput {
|
||||
data_type,
|
||||
resolved_type,
|
||||
name,
|
||||
description,
|
||||
valid_types: self.potential_valid_input_types(input_connector, network_path).iter().map(|ty| ty.to_string()).collect(),
|
||||
valid_types,
|
||||
connected_to,
|
||||
})
|
||||
}
|
||||
@@ -698,7 +705,7 @@ impl NodeNetworkInterface {
|
||||
|
||||
let import_name = if !import_name.is_empty() {
|
||||
import_name
|
||||
} else if let Some(import_type_name) = output_type.compiled_nested_type().map(|nested| nested.to_string()) {
|
||||
} else if let Some(import_type_name) = output_type.compiled_nested_type().map(ToString::to_string) {
|
||||
import_type_name
|
||||
} else {
|
||||
format!("Import #{}", import_index)
|
||||
|
||||
@@ -91,8 +91,8 @@ impl TypeSource {
|
||||
/// The type to display in the tooltip label.
|
||||
pub fn resolved_type_tooltip_string(&self) -> String {
|
||||
match self {
|
||||
TypeSource::Compiled(compiled_type) => format!("Data Type: {:?}", compiled_type.nested_type().to_string()),
|
||||
TypeSource::TaggedValue(value_type) => format!("Data Type: {:?}", value_type.nested_type().to_string()),
|
||||
TypeSource::Compiled(compiled_type) => format!("Data Type: {}", compiled_type.nested_type()),
|
||||
TypeSource::TaggedValue(value_type) => format!("Data Type: {}", value_type.nested_type()),
|
||||
TypeSource::Unknown => "Unknown Data Type".to_string(),
|
||||
TypeSource::Invalid => "Invalid Type Combination".to_string(),
|
||||
TypeSource::Error(_) => "Error Getting Data Type".to_string(),
|
||||
@@ -180,7 +180,7 @@ impl NodeNetworkInterface {
|
||||
self.input_type_not_invalid(input_connector, network_path)
|
||||
}
|
||||
|
||||
// Gets the default tagged value for an input. If its not compiled, then it tries to get a valid type. If there are no valid types, then it picks a random implementation
|
||||
/// Gets the default tagged value for an input. If its not compiled, then it tries to get a valid type. If there are no valid types, then it picks a random implementation.
|
||||
pub fn tagged_value_from_input(&mut self, input_connector: &InputConnector, network_path: &[NodeId]) -> TaggedValue {
|
||||
let guaranteed_type = match self.input_type(input_connector, network_path) {
|
||||
TypeSource::Compiled(compiled) => compiled,
|
||||
@@ -190,12 +190,12 @@ impl NodeNetworkInterface {
|
||||
// TODO: Add a NodeInput::Indeterminate which can be resolved at compile time to be any type that prevents an error. This may require bidirectional typing.
|
||||
self.complete_valid_input_types(input_connector, network_path)
|
||||
.into_iter()
|
||||
.min_by_key(|ty| ty.nested_type().to_string())
|
||||
.min_by_key(|ty| ty.nested_type().identifier_name())
|
||||
// Pick a random type from the potential valid types
|
||||
.or_else(|| {
|
||||
self.potential_valid_input_types(input_connector, network_path)
|
||||
.into_iter()
|
||||
.min_by_key(|ty| ty.nested_type().to_string())
|
||||
.min_by_key(|ty| ty.nested_type().identifier_name())
|
||||
}).unwrap_or(concrete!(()))
|
||||
}
|
||||
TypeSource::Error(e) => {
|
||||
|
||||
Reference in New Issue
Block a user