From 6f0ffa44c1bca2927e3e1a337fa1ce7349bd0e66 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 4 Jan 2013 14:50:37 +0100 Subject: ephy-shell: There can be two widgets for the same download in WebKit2 In WebKit2 WebKitWebContext::download-started signal is always emitted, even for downloads started manually. We only want to create a new download when the download operation has been started by WebKit. https://bugzilla.gnome.org/show_bug.cgi?id=678993 --- src/ephy-shell.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 1ae07ac6a..452ded781 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -595,10 +595,9 @@ download_started_cb (WebKitWebContext *web_context, WebKitDownload *download, EphyShell *shell) { - EphyDownload *ed; GtkWindow *window = NULL; WebKitWebView *web_view; - GtkWidget *toplevel; + gboolean ephy_download_set; /* Is download locked down? */ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, @@ -607,6 +606,15 @@ download_started_cb (WebKitWebContext *web_context, return; } + /* Only create an EphyDownload for the WebKitDownload if it doesn't exist yet. + * This can happen when the download has been started automatically by WebKit, + * due to a context menu action or policy checker decision. Downloads started + * explicitly by Epiphany are marked with ephy-download-set GObject data. + */ + ephy_download_set = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (download), "ephy-download-set")); + if (ephy_download_set) + return; + web_view = webkit_download_get_web_view (download); if (web_view) { GtkWidget *toplevel; @@ -619,7 +627,7 @@ download_started_cb (WebKitWebContext *web_context, if (!window) window = gtk_application_get_active_window (GTK_APPLICATION (shell)); - ed = ephy_download_new_for_download (download, window); + ephy_download_new_for_download (download, window); } #endif -- cgit v1.2.3