From 203c86e807b9494e839bef3816003b1a5de32003 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Thu, 16 Jul 2015 22:40:06 +0200 Subject: [PATCH] Use provisional uri if page could not be loaded (#224). In case an uri could not be loaded the uri of the webview is still the previous one. That means the url shown in the url bar is not the user requested and the 'O' command would also use the wrong url. To fix this the provisional uri is used for the url bar as well as for the autocmd call if the load of the uri failed. --- src/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 4f026d9..f229e10 100644 --- a/src/main.c +++ b/src/main.c @@ -783,10 +783,19 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) break; case WEBKIT_LOAD_FAILED: + { + /* In case the requested uri could not be loaded the Current + * uri of the Webview would still be the PRevious one. So We + * use the provisional uri here. */ + WebKitWebFrame *frame = webkit_web_view_get_main_frame(view); + WebKitWebDataSource *src = webkit_web_frame_get_provisional_data_source(frame); + WebKitNetworkRequest *req = webkit_web_data_source_get_initial_request(src); + uri = webkit_network_request_get_uri(req); + vb_update_urlbar(uri); #ifdef FEATURE_AUTOCMD - uri = webkit_web_view_get_uri(view); - autocmd_run(AU_LOAD_FAILED, uri, NULL); + autocmd_run(AU_LOAD_FAILED, uri, NULL); #endif + } break; } } -- 2.20.1