[librsvg: 1/6] pattern: store the weak ref to node in resolve()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/6] pattern: store the weak ref to node in resolve()
- Date: Sat, 29 Jun 2019 21:50:31 +0000 (UTC)
commit 03cbbe9628ac15eb9631388656d4122116582f97
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Jun 29 11:11:59 2019 +0200
pattern: store the weak ref to node in resolve()
The weak ref to the node is only used during the resolution and
we have the node as a parameter to resolve(), so store it there
rather than in the initial set_atts
rsvg_internals/src/pattern.rs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index c2db4429..9f9aa2ee 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -128,11 +128,9 @@ impl Default for NodePattern {
}
impl NodeTrait for NodePattern {
- fn set_atts(&self, node: &RsvgNode, pbag: &PropertyBag<'_>) -> NodeResult {
+ fn set_atts(&self, _node: &RsvgNode, pbag: &PropertyBag<'_>) -> NodeResult {
let mut p = self.pattern.borrow_mut();
- p.node = Some(node.downgrade());
-
for (attr, value) in pbag.iter() {
match attr {
local_name!("patternUnits") => p.units = Some(attr.parse(value)?),
@@ -186,6 +184,12 @@ impl PaintSource for NodePattern {
draw_ctx: &mut DrawingCtx,
_bbox: &BoundingBox,
) -> Result<Option<Self::Source>, RenderingError> {
+ {
+ // Initialize pattern.node and release the mutable borrow
+ let mut p = self.pattern.borrow_mut();
+ p.node = Some(node.downgrade());
+ }
+
let mut result = node
.borrow()
.get_impl::<NodePattern>()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]