diff options
author | Paweł Zuzelski <pawelz@pld-linux.org> | 2010-01-25 13:33:18 +0100 |
---|---|---|
committer | Paweł Zuzelski <pawelz@pld-linux.org> | 2010-01-25 13:33:18 +0100 |
commit | ae6bf040f7a19ed075caf2b06bb3fcd85cfdfba4 (patch) | |
tree | 14766aaa096afc61403fc1a668910865be330975 | |
parent | 0036e7b2ed977f92020b975407f2b55b56c6bcda (diff) |
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.
-rw-r--r-- | src/callbacks.c | 20 |
1 files 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; } |