From 1582f0c7dcac898cbebda188c86071bcc32ecb03 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 31 Oct 2017 05:12:23 -0400 Subject: MqWebView: Invalidate main resource data cache on load change Otherwise, a connected source view will keep getting the data the first such view received, even after a load change. A better solution would be to cache a pointer to the main resource and check in mq_web_view_get_data() if the main resource's address has changed. But apparently WebKit reuses resource objects, so that doesn't work. --- (limited to 'src/web-view.c') diff --git a/src/web-view.c b/src/web-view.c index 01800b8..67e71cd 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -60,6 +60,13 @@ struct _MqWebViewClass { G_DEFINE_TYPE(MqWebView, mq_web_view, WEBKIT_TYPE_WEB_VIEW) +static void +load_changed_cb(MqWebView *web_view, WebKitLoadEvent G_GNUC_UNUSED load_event) +{ + g_free(web_view->data); + web_view->data = NULL; +} + static gboolean context_menu_cb(MqWebView *web_view, WebKitContextMenu *context_menu, GdkEvent *event, WebKitHitTestResult *hit_test_result) @@ -325,6 +332,8 @@ mq_web_view_class_init(MqWebViewClass *klass) static void mq_web_view_init(MqWebView *web_view) { + g_signal_connect(web_view, "load-changed", + G_CALLBACK(load_changed_cb), NULL); g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL); g_signal_connect(web_view, "notify::uri", -- cgit v0.9.1