[librsvg/librsvg-2.44] AcquiredNodes: Use a Rc<...> instead of a raw pointer into the Vec of acquired nodes
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.44] AcquiredNodes: Use a Rc<...> instead of a raw pointer into the Vec of acquired nodes
- Date: Wed, 19 Sep 2018 18:23:58 +0000 (UTC)
commit ed69cde4c64a7b71bed80bcb668cd901f01559dc
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Sep 19 09:23:51 2018 -0500
AcquiredNodes: Use a Rc<...> instead of a raw pointer into the Vec of acquired nodes
Similar to how the view_box_stack is done.
rsvg_internals/src/drawing_ctx.rs | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 556d1804..0b22d6c7 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -73,7 +73,7 @@ pub struct DrawingCtx<'a> {
drawsub_stack: Vec<RsvgNode>,
defs: RefCell<&'a mut Defs>,
- acquired_nodes: RefCell<Vec<RsvgNode>>,
+ acquired_nodes: Rc<RefCell<Vec<RsvgNode>>>,
is_testing: bool,
}
@@ -125,7 +125,7 @@ impl<'a> DrawingCtx<'a> {
bbox_stack: Vec::new(),
drawsub_stack: Vec::new(),
defs: RefCell::new(defs),
- acquired_nodes: RefCell::new(Vec::new()),
+ acquired_nodes: Rc::new(RefCell::new(Vec::new())),
is_testing,
}
}
@@ -213,7 +213,7 @@ impl<'a> DrawingCtx<'a> {
if let Some(node) = self.defs.borrow_mut().lookup(url) {
if !self.acquired_nodes_contains(node) {
self.acquired_nodes.borrow_mut().push(node.clone());
- return Some(AcquiredNode(&self.acquired_nodes as *const _, node.clone()));
+ return Some(AcquiredNode(self.acquired_nodes.clone(), node.clone()));
}
}
@@ -1026,15 +1026,13 @@ pub extern "C" fn rsvg_drawing_ctx_get_ink_rect(
res.to_glib()
}
-pub struct AcquiredNode(*const RefCell<Vec<RsvgNode>>, RsvgNode);
+pub struct AcquiredNode(Rc<RefCell<Vec<RsvgNode>>>, RsvgNode);
impl Drop for AcquiredNode {
fn drop(&mut self) {
- unsafe {
- let mut v = (*self.0).borrow_mut();
- assert!(Rc::ptr_eq(v.last().unwrap(), &self.1));
- v.pop();
- }
+ let mut v = self.0.borrow_mut();
+ assert!(Rc::ptr_eq(v.last().unwrap(), &self.1));
+ v.pop();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]