Commit b7e269f0 authored by Michael Catanzaro's avatar Michael Catanzaro

downloads-manager: Fix crash when download fails

It's wrong to acquire the session inhibitor when destination is created,
because the download could fail before that point, causing the
inhibitotr to be released before it has been acquired and triggering our
assertions to ensure this does not happen.

Instead, acquire the inhibitor immediately when creating the download.

https://bugzilla.gnome.org/show_bug.cgi?id=778653
parent ab33eebf
......@@ -159,12 +159,6 @@ download_estimated_progress_changed_cb (EphyDownloadsManager *manager)
g_signal_emit (manager, signals[ESTIMATED_PROGRESS_CHANGED], 0);
}
static void
download_created_destination_cb (EphyDownloadsManager *manager)
{
ephy_downloads_manager_acquire_session_inhibitor (manager);
}
void
ephy_downloads_manager_add_download (EphyDownloadsManager *manager,
EphyDownload *download)
......@@ -177,6 +171,8 @@ ephy_downloads_manager_add_download (EphyDownloadsManager *manager,
if (g_list_find (manager->downloads, download))
return;
ephy_downloads_manager_acquire_session_inhibitor (manager);
manager->downloads = g_list_prepend (manager->downloads, g_object_ref (download));
g_signal_connect (download, "completed",
G_CALLBACK (download_completed_cb),
......@@ -189,9 +185,6 @@ ephy_downloads_manager_add_download (EphyDownloadsManager *manager,
g_signal_connect_swapped (wk_download, "notify::estimated-progress",
G_CALLBACK (download_estimated_progress_changed_cb),
manager);
g_signal_connect_swapped (wk_download, "created-destination",
G_CALLBACK (download_created_destination_cb),
manager);
g_signal_emit (manager, signals[DOWNLOAD_ADDED], 0, download);
g_signal_emit (manager, signals[ESTIMATED_PROGRESS_CHANGED], 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment