[epiphany] web-view: Fix memory leaks when web view is closed before info bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] web-view: Fix memory leaks when web view is closed before info bar
- Date: Sat, 14 Jan 2017 21:23:37 +0000 (UTC)
commit f640b27ab4893d147b60b94929c6ae5e149aa7b5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Jan 14 15:18:21 2017 -0600
web-view: Fix memory leaks when web view is closed before info bar
The current info bar management code improperly assumes that the user
will always close the info bar before closing its associated web view.
If the user closes the web view first, then we leak the FormAuthData
or PermissionRequestData struct in EphyWebView. In the case of
PermissionRequestData, that notably contains an unresolved
WebKitPermissionRequest. Additionally, for form auth data requests, the
hash table entry for the outstanding request in the web extension is
leaked because the web extension never receives the expected form auth
data request response.
Resolve this by tracking the destruction of the info bars with a weak
reference.
embed/ephy-web-view.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 29a3de5..95abda4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -707,12 +707,22 @@ form_auth_request_data_free (FormAuthRequestData *data)
}
static void
+form_auth_save_confirmation_info_bar_destroyed_cb (FormAuthRequestData *data,
+ GObject *where_the_info_bar_was)
+{
+ /* Ensure the hash table entry in the web process is removed. */
+ if (data->web_view->web_extension)
+ ephy_web_extension_proxy_form_auth_data_save_confirmation_response (data->web_view->web_extension,
+ data->request_id,
+ FALSE);
+ form_auth_request_data_free (data);
+}
+
+static void
form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
gint response_id,
FormAuthRequestData *data)
{
- gtk_widget_destroy (GTK_WIDGET (info_bar));
-
if (data->web_view->web_extension) {
ephy_web_extension_proxy_form_auth_data_save_confirmation_response (data->web_view->web_extension,
data->request_id,
@@ -729,6 +739,8 @@ form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
EPHY_HOST_PERMISSION_DENY);
}
+ g_object_weak_unref (G_OBJECT (info_bar), (GWeakNotify)form_auth_save_confirmation_info_bar_destroyed_cb,
data);
+ gtk_widget_destroy (GTK_WIDGET (info_bar));
form_auth_request_data_free (data);
}
@@ -758,6 +770,7 @@ form_auth_data_save_requested (EphyEmbedShell *shell,
g_signal_connect (info_bar, "response",
G_CALLBACK (form_auth_data_save_confirmation_response),
data);
+ g_object_weak_ref (G_OBJECT (info_bar), (GWeakNotify)form_auth_save_confirmation_info_bar_destroyed_cb,
data);
gtk_widget_show (info_bar);
}
@@ -1311,6 +1324,14 @@ permission_request_data_free (PermissionRequestData *data)
}
static void
+permission_request_info_bar_destroyed_cb (PermissionRequestData *data,
+ GObject *where_the_info_bar_was)
+{
+ webkit_permission_request_deny (data->request);
+ permission_request_data_free (data);
+}
+
+static void
decide_on_permission_request (GtkWidget *info_bar,
int response,
PermissionRequestData *data)
@@ -1356,6 +1377,7 @@ decide_on_permission_request (GtkWidget *info_bar,
: EPHY_HOST_PERMISSION_DENY);
}
+ g_object_weak_unref (G_OBJECT (info_bar), (GWeakNotify)permission_request_info_bar_destroyed_cb, data);
gtk_widget_destroy (info_bar);
permission_request_data_free (data);
}
@@ -1425,6 +1447,7 @@ show_permission_request_info_bar (WebKitWebView *web_view,
g_signal_connect (info_bar, "response",
G_CALLBACK (decide_on_permission_request),
data);
+ g_object_weak_ref (G_OBJECT (info_bar), (GWeakNotify)permission_request_info_bar_destroyed_cb, data);
g_free (host);
switch (permission_type) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]