/pidgin/main: 88b2504d0acf: Fix an warning with selections. Sele...

Elliott Sales de Andrade qulogic at pidgin.im
Tue Aug 14 04:03:26 EDT 2012


Changeset: 88b2504d0acffff2cbc2aa7de1309fa2ff5e52c6
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-08-13 03:41 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/88b2504d0acf

Description:

Fix an warning with selections. Selections are weird.

diffstat:

 pidgin/gtkwebview.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (27 lines):

diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -1221,16 +1221,20 @@ gtk_webview_get_selected_text(GtkWebView
 	WebKitDOMDocument *dom;
 	WebKitDOMDOMWindow *win;
 	WebKitDOMDOMSelection *sel;
-	WebKitDOMRange *range;
+	WebKitDOMRange *range = NULL;
 
 	g_return_val_if_fail(webview != NULL, NULL);
 
 	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
 	win = webkit_dom_document_get_default_view(dom);
 	sel = webkit_dom_dom_window_get_selection(win);
-	range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
+	if (webkit_dom_dom_selection_get_range_count(sel))
+		range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
 
-	return webkit_dom_range_get_text(range);
+	if (range)
+		return webkit_dom_range_get_text(range);
+	else
+		return NULL;
 }
 
 GtkWebViewButtons



More information about the Commits mailing list