From ae6bf040f7a19ed075caf2b06bb3fcd85cfdfba4 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Mon, 25 Jan 2010 13:33:18 +0100 Subject: check if feature is set before (un)setting feature Don't try to set WEBKIT_TYPE_SOUP_AUTH_DIALOG in set_authentication_handler() if it is already set. Don't try to unset it if it is not set. --- src/callbacks.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/callbacks.c b/src/callbacks.c index 3aa70fb..59c6dc2 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -28,12 +28,20 @@ set_proxy_url() { void set_authentication_handler() { - if (uzbl.behave.authentication_handler == NULL || *uzbl.behave.authentication_handler == NULL) - soup_session_add_feature_by_type - (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); - else - soup_session_remove_feature_by_type - (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); + /* Check if WEBKIT_TYPE_SOUP_AUTH_DIALOG feature is set */ + GSList *flist = soup_session_get_features (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); + guint feature_is_set = g_slist_length(flist); + g_slist_free(flist); + + if (uzbl.behave.authentication_handler == NULL || *uzbl.behave.authentication_handler == NULL) { + if (!feature_is_set) + soup_session_add_feature_by_type + (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); + } else { + if (feature_is_set) + soup_session_remove_feature_by_type + (uzbl.net.soup_session, (GType) WEBKIT_TYPE_SOUP_AUTH_DIALOG); + } return; } -- cgit v1.2.3