mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-02 20:42:16 +00:00
fix crash when shape does not have fill (#557)
This commit is contained in:
parent
a73d9b5811
commit
37476fc19d
1 changed files with 12 additions and 12 deletions
|
@ -258,16 +258,16 @@ fn register_layer_properties(layer: &Layer, responses: &mut VecDeque<Message>) {
|
|||
vec![]
|
||||
}
|
||||
LayerDataType::Shape(shape) => {
|
||||
vec![
|
||||
node_section_transform(layer),
|
||||
node_section_fill(&shape.style.fill()),
|
||||
node_section_stroke(&shape.style.stroke().unwrap_or_default()),
|
||||
]
|
||||
if let Some(fill_layout) = node_section_fill(&shape.style.fill()) {
|
||||
vec![node_section_transform(layer), fill_layout, node_section_stroke(&shape.style.stroke().unwrap_or_default())]
|
||||
} else {
|
||||
vec![node_section_transform(layer), node_section_stroke(&shape.style.stroke().unwrap_or_default())]
|
||||
}
|
||||
}
|
||||
LayerDataType::Text(text) => {
|
||||
vec![
|
||||
node_section_transform(layer),
|
||||
node_section_fill(&text.style.fill()),
|
||||
node_section_fill(&text.style.fill()).expect("Text should have fill"),
|
||||
node_section_stroke(&text.style.stroke().unwrap_or_default()),
|
||||
]
|
||||
}
|
||||
|
@ -409,9 +409,9 @@ fn node_section_transform(layer: &Layer) -> LayoutRow {
|
|||
}
|
||||
}
|
||||
|
||||
fn node_section_fill(fill: &Fill) -> LayoutRow {
|
||||
fn node_section_fill(fill: &Fill) -> Option<LayoutRow> {
|
||||
match fill {
|
||||
Fill::Solid(color) => LayoutRow::Section {
|
||||
Fill::Solid(color) => Some(LayoutRow::Section {
|
||||
name: "Fill".into(),
|
||||
layout: vec![LayoutRow::Row {
|
||||
name: "".into(),
|
||||
|
@ -437,11 +437,11 @@ fn node_section_fill(fill: &Fill) -> LayoutRow {
|
|||
})),
|
||||
],
|
||||
}],
|
||||
},
|
||||
}),
|
||||
Fill::LinearGradient(gradient) => {
|
||||
let gradient_1 = Rc::new(gradient.clone());
|
||||
let gradient_2 = gradient_1.clone();
|
||||
LayoutRow::Section {
|
||||
Some(LayoutRow::Section {
|
||||
name: "Fill".into(),
|
||||
layout: vec![
|
||||
LayoutRow::Row {
|
||||
|
@ -501,9 +501,9 @@ fn node_section_fill(fill: &Fill) -> LayoutRow {
|
|||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
})
|
||||
}
|
||||
Fill::None => panic!("`node_section_fill` called on a shape that does not have a fill"),
|
||||
Fill::None => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue