[evolution] EWebView - If the parent of the node that we want to remove doesn't exist, just free it



commit 0d437729dfb2314a82f3953cfc1c4983ca6646a3
Author: Tomas Popela <tpopela redhat com>
Date:   Sun Aug 17 09:03:13 2014 +0200

    EWebView - If the parent of the node that we want to remove doesn't exist, just free it

 e-util/e-web-view.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 8a3b9c7..df89e8d 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -3529,8 +3529,15 @@ element_remove_class (WebKitDOMElement *element,
 void
 remove_node (WebKitDOMNode *node)
 {
-       webkit_dom_node_remove_child (
-               webkit_dom_node_get_parent_node (node), node, NULL);
+       WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
+
+       /* Check if the parent exists, if so it means that the node is still
+        * in the DOM or at least the parent is. If it doesn't exists it is not
+        * in the DOM and we can free it. */
+       if (parent)
+               webkit_dom_node_remove_child (parent, node, NULL);
+       else
+               g_object_unref (node);
 }
 
 void


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