From: Ingo Ruhnke Date: Tue, 26 Aug 2014 22:56:32 +0000 (+0200) Subject: Moved abort() and update() calls into TransferStatus, also fixed abort() handling... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1c20c86780300c17e5e27802ecea29f8cc0ed49f;p=supertux.git Moved abort() and update() calls into TransferStatus, also fixed abort() handling, then-callbacks are now called --- diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index a624bc564..60099bf4c 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -598,14 +598,4 @@ AddonManager::update() m_downloader.update(); } -void -AddonManager::abort_install() -{ - log_info << "addon install aborted" << std::endl; - - m_downloader.abort(m_transfer_status->id); - - m_transfer_status = {}; -} - /* EOF */ diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 92b38e526..fafebb0da 100644 --- a/src/addon/addon_manager.hpp +++ b/src/addon/addon_manager.hpp @@ -71,7 +71,6 @@ public: Addon& get_installed_addon(const AddonId& addon); TransferStatusPtr request_install_addon(const AddonId& addon_id); - void abort_install(); void install_addon(const AddonId& addon_id); void uninstall_addon(const AddonId& addon_id); diff --git a/src/addon/downloader.cpp b/src/addon/downloader.cpp index b923813f5..80a55757c 100644 --- a/src/addon/downloader.cpp +++ b/src/addon/downloader.cpp @@ -49,6 +49,12 @@ size_t my_curl_physfs_write(void* ptr, size_t size, size_t nmemb, void* userdata } // namespace void +TransferStatus::abort() +{ + m_downloader.abort(id); +} + +void TransferStatus::update() { m_downloader.update(); @@ -258,8 +264,22 @@ Downloader::abort(TransferId id) } else { + TransferStatusPtr status = (*it)->get_status(); + curl_multi_remove_handle(m_multi_handle, (*it)->get_curl_handle()); m_transfers.erase(it); + + for(auto& callback : status->callbacks) + { + try + { + callback(false); + } + catch(const std::exception& err) + { + log_warning << "Illegal exception in Downloader: " << err.what() << std::endl; + } + } } } diff --git a/src/addon/downloader.hpp b/src/addon/downloader.hpp index c75c7e1f4..6e7e48266 100644 --- a/src/addon/downloader.hpp +++ b/src/addon/downloader.hpp @@ -53,6 +53,7 @@ public: error_msg() {} + void abort(); void update(); void then(const std::function& callback) diff --git a/src/supertux/menu/download_dialog.cpp b/src/supertux/menu/download_dialog.cpp index 910dad078..17864e0be 100644 --- a/src/supertux/menu/download_dialog.cpp +++ b/src/supertux/menu/download_dialog.cpp @@ -84,7 +84,7 @@ DownloadDialog::update_text() void DownloadDialog::on_abort() { - AddonManager::current()->abort_install(); + m_status->abort(); } void