[librsvg] Node.get_parent() - new method; returns a strong Rc<Node>



commit 11e32a86153deb16501a55490dd391650e5bef96
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Mar 22 16:28:51 2017 -0600

    Node.get_parent() - new method; returns a strong Rc<Node>
    
    Reimplement rsvg_node_get_parent() in terms of it.

 rust/src/node.rs |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/rust/src/node.rs b/rust/src/node.rs
index 1be2a5e..36a426d 100644
--- a/rust/src/node.rs
+++ b/rust/src/node.rs
@@ -152,6 +152,13 @@ impl Node {
         self.state
     }
 
+    pub fn get_parent (&self) -> Option<Rc<Node>> {
+        match self.parent {
+            None => None,
+            Some (ref weak_node) => Some (weak_node.upgrade ().unwrap ())
+        }
+    }
+
     pub fn add_child (&self, child: &Rc<Node>) {
         self.children.borrow_mut ().push (child.clone ());
     }
@@ -253,12 +260,11 @@ pub extern fn rsvg_node_get_parent (raw_node: *const RsvgNode) -> *const RsvgNod
     assert! (!raw_node.is_null ());
     let node: &RsvgNode = unsafe { & *raw_node };
 
-    match node.parent {
+    match node.get_parent () {
         None => { ptr::null () }
 
-        Some (ref weak_node) => {
-            let strong_node = weak_node.upgrade ().unwrap ();
-            box_node (strong_node)
+        Some (node) => {
+            box_node (node)
         }
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]