[librsvg: 2/28] NodePath: Store an Option<RsvgPathBuilder> instead of an empty builder
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/28] NodePath: Store an Option<RsvgPathBuilder> instead of an empty builder
- Date: Tue, 23 Jan 2018 17:59:23 +0000 (UTC)
commit bdd41820209e7a2815cb1a34e25fd4e3bbf500a9
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jan 23 08:44:26 2018 -0600
NodePath: Store an Option<RsvgPathBuilder> instead of an empty builder
rust/src/shapes.rs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/rust/src/shapes.rs b/rust/src/shapes.rs
index 07516bc..c1cc421 100644
--- a/rust/src/shapes.rs
+++ b/rust/src/shapes.rs
@@ -76,13 +76,13 @@ fn render_ellipse (cx: f64,
/***** NodePath *****/
struct NodePath {
- builder: RefCell<RsvgPathBuilder>
+ builder: RefCell<Option<RsvgPathBuilder>>
}
impl NodePath {
fn new () -> NodePath {
NodePath {
- builder: RefCell::new (RsvgPathBuilder::new ())
+ builder: RefCell::new (None)
}
}
}
@@ -90,19 +90,23 @@ impl NodePath {
impl NodeTrait for NodePath {
fn set_atts (&self, _: &RsvgNode, _: *const RsvgHandle, pbag: *const RsvgPropertyBag) -> NodeResult {
if let Some (value) = property_bag::lookup (pbag, "d") {
- let mut builder = self.builder.borrow_mut ();
+ let mut builder = RsvgPathBuilder::new ();
- if path_parser::parse_path_into_builder (&value, &mut *builder).is_err() {
+ if path_parser::parse_path_into_builder (&value, &mut builder).is_err() {
// FIXME: we don't propagate errors upstream, but creating a partial
// path is OK per the spec
}
+
+ *self.builder.borrow_mut() = Some(builder);
}
Ok (())
}
fn draw (&self, node: &RsvgNode, draw_ctx: *const RsvgDrawingCtx, dominate: i32) {
- render_path_builder (&*self.builder.borrow (), draw_ctx, node.get_state (), dominate, true);
+ if let Some(ref builder) = *self.builder.borrow() {
+ render_path_builder (builder, draw_ctx, node.get_state (), dominate, true);
+ }
}
fn get_c_impl (&self) -> *const RsvgCNodeImpl {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]