/pidgin/main: 88714527fcb3: Fix invalid gobject cast

Tomasz Wasilczyk twasilczyk at pidgin.im
Sat Apr 26 08:41:59 EDT 2014


Changeset: 88714527fcb31e33962343dc53e70c2373637e18
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-26 14:41 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/88714527fcb3

Description:

Fix invalid gobject cast

diffstat:

 pidgin/gtkwebview.c |  35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diffs (50 lines):

diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -932,27 +932,30 @@ static gboolean
 webview_popup_menu(WebKitWebView *webview)
 {
 	WebKitDOMDocument *doc;
-	WebKitDOMElement *active;
-	WebKitDOMElement *link;
-	int context;
-	char *uri;
-
-	context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
-	uri = NULL;
+	WebKitDOMNode *node = NULL;
+	int context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
+	char *uri = NULL;
 
 	doc = webkit_web_view_get_dom_document(webview);
-	active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc));
-
-	link = active;
-	while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link))
-		link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link));
-	if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) {
-		context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
-		uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link));
+
+	/* it's unlikely, at least for webkit 1.x */
+	if (WEBKIT_DOM_IS_HTML_DOCUMENT(doc)) {
+		WebKitDOMElement *active;
+		WebKitDOMElement *link;
+		active = webkit_dom_html_document_get_active_element(
+			WEBKIT_DOM_HTML_DOCUMENT(doc));
+
+		link = active;
+		while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link))
+			link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link));
+		if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) {
+			context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
+			uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link));
+		}
 	}
 
 	do_popup_menu(webview, 0, gtk_get_current_event_time(),
-	              context, WEBKIT_DOM_NODE(active), uri);
+		context, node, uri);
 
 	g_free(uri);
 



More information about the Commits mailing list