diff options
author | Diego Escalante Urrelo <descalante@igalia.com> | 2010-03-11 05:43:30 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <descalante@igalia.com> | 2010-03-16 07:29:58 +0800 |
commit | 355994be201180a7d695844114fb465d0a5b9b39 (patch) | |
tree | bc7adeab31e9099f404f0d8956220db82d6e0cb3 /embed | |
parent | 50cd4276088499093b428b54195a88c4b7a1a0ad (diff) | |
download | gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar.gz gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar.bz2 gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar.lz gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar.xz gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.tar.zst gsoc2013-epiphany-355994be201180a7d695844114fb465d0a5b9b39.zip |
downloader-view: change lifetime logic
The DV follows the same goal as before (being alive while there are downloads).
Now every download holds a reference to the DV and releases it when the
download is removed (finished, cancelled, etc).
The DV clears its own reference once and only once when a download is removed
and there are no more downloads in queue.
Bug #611779
Diffstat (limited to 'embed')
-rw-r--r-- | embed/downloader-view.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 7fbb1e54b..db4e8eec9 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -69,6 +69,7 @@ struct _DownloaderViewPrivate GtkWidget *abort_button; GtkStatusIcon *status_icon; + gboolean ownref; #ifdef HAVE_LIBNOTIFY NotifyNotification *notification; @@ -225,6 +226,7 @@ remove_download (WebKitDownload *download, webkit_download_cancel (download); g_object_unref (download); + g_object_unref (dv); return TRUE; } @@ -261,6 +263,8 @@ downloader_view_init (DownloaderView *dv) downloader_view_build_ui (dv); + dv->priv->ownref = TRUE; + show_status_icon (dv); g_signal_connect_object (embed_shell, "prepare_close", @@ -706,7 +710,7 @@ downloader_view_add_download (DownloaderView *dv, update_status_icon (dv); selection = gtk_tree_view_get_selection - (GTK_TREE_VIEW(dv->priv->treeview)); + (GTK_TREE_VIEW (dv->priv->treeview)); gtk_tree_selection_unselect_all (selection); gtk_tree_selection_select_iter (selection, &iter); @@ -789,9 +793,6 @@ downloader_view_add_download (DownloaderView *dv, #endif dv->priv->source_id = g_timeout_add (100, (GSourceFunc) update_buttons_timeout_cb, dv); - - /* see above */ - g_object_unref (dv); } static void @@ -1038,7 +1039,12 @@ downloader_view_remove_download (DownloaderView *dv, WebKitDownload *download) gtk_widget_set_sensitive (dv->priv->abort_button, FALSE); gtk_widget_set_sensitive (dv->priv->pause_button, FALSE); ephy_dialog_hide (EPHY_DIALOG (dv)); - g_object_unref (dv); + + if (dv->priv->ownref) + { + dv->priv->ownref = FALSE; + g_object_unref (dv); + } } } |