mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 02:43:46 +00:00
Addon client: close connection if the player cancels the download
This ensures that the game won't interpret the rest of the addon as a response for the client's next request. Fixes #2203.
This commit is contained in:
parent
03b6ad568c
commit
c9ec111cf1
@ -61,6 +61,7 @@ Version 1.13.10+dev:
|
||||
* Macro SCEPTRE_OF_FIRE_EFFECT damage increased to 15x4 so Sceptre is an
|
||||
improvement over the uncut ruby of fire (14x4) in TRoW.
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fixed crash after canceling add-on download (bug #2203)
|
||||
* Fixed ingame help showing units you haven't encountered (bug #2135)
|
||||
* Fixed the opacity IPF resetting to 0 if the value given was 100% or
|
||||
greater (bug #2185).
|
||||
|
@ -24,6 +24,7 @@ Version 1.13.10+dev:
|
||||
* Miscellaneous low-level optimizations in game rendering code, improving
|
||||
performance ingame by up to 50 %.
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fixed crash after canceling add-on download (bug #2203)
|
||||
* Fixed ingame help showing units you haven't encountered (bug #2135)
|
||||
* Fix recalls updating shroud immediately when "Delay Shroud Updates" is set
|
||||
(bug #2196)
|
||||
|
@ -43,7 +43,6 @@ addons_client::addons_client(const std::string& address)
|
||||
, host_()
|
||||
, port_()
|
||||
, conn_(nullptr)
|
||||
, stat_(nullptr)
|
||||
, last_error_()
|
||||
, last_error_data_()
|
||||
{
|
||||
@ -516,40 +515,40 @@ void addons_client::send_simple_request(const std::string& request_string, confi
|
||||
}
|
||||
struct read_addon_connection_data : public network_transmission::connection_data
|
||||
{
|
||||
read_addon_connection_data(network_asio::connection& conn) : conn_(conn) {}
|
||||
read_addon_connection_data(network_asio::connection& conn, addons_client& client)
|
||||
: conn_(conn), client_(client) {}
|
||||
size_t total() override { return conn_.bytes_to_read(); }
|
||||
virtual size_t current() override { return conn_.bytes_read(); }
|
||||
virtual bool finished() override { return conn_.done(); }
|
||||
virtual void cancel() override { return conn_.cancel(); }
|
||||
virtual void cancel() override { client_.connect(); }
|
||||
virtual void poll() override { conn_.poll(); }
|
||||
network_asio::connection& conn_;
|
||||
addons_client& client_;
|
||||
};
|
||||
struct write_addon_connection_data : public network_transmission::connection_data
|
||||
{
|
||||
write_addon_connection_data(network_asio::connection& conn) : conn_(conn) {}
|
||||
write_addon_connection_data(network_asio::connection& conn, addons_client& client)
|
||||
: conn_(conn), client_(client) {}
|
||||
size_t total() override { return conn_.bytes_to_write(); }
|
||||
virtual size_t current() override { return conn_.bytes_written(); }
|
||||
virtual bool finished() override { return conn_.done(); }
|
||||
virtual void cancel() override { return conn_.cancel(); }
|
||||
virtual void cancel() override { client_.connect(); }
|
||||
virtual void poll() override { conn_.poll(); }
|
||||
network_asio::connection& conn_;
|
||||
addons_client& client_;
|
||||
};
|
||||
void addons_client::wait_for_transfer_done(const std::string& status_message, bool track_upload)
|
||||
{
|
||||
check_connected();
|
||||
std::unique_ptr<network_transmission::connection_data> cd;
|
||||
if(track_upload)
|
||||
cd.reset(new write_addon_connection_data{ *conn_ });
|
||||
cd.reset(new write_addon_connection_data{*conn_, *this});
|
||||
else
|
||||
cd.reset(new read_addon_connection_data{ *conn_ });
|
||||
if(!stat_) {
|
||||
stat_.reset(new network_transmission(*cd, _("Add-ons Manager"), status_message));
|
||||
} else {
|
||||
stat_->set_subtitle(status_message);
|
||||
stat_->set_connection_data(*cd);
|
||||
}
|
||||
cd.reset(new read_addon_connection_data{*conn_, *this});
|
||||
|
||||
if(!stat_->show()) {
|
||||
gui2::dialogs::network_transmission stat(*cd, _("Add-ons Manager"), status_message);
|
||||
|
||||
if(!stat.show()) {
|
||||
// Notify the caller chain that the user aborted the operation.
|
||||
throw user_exit();
|
||||
}
|
||||
|
@ -122,7 +122,6 @@ private:
|
||||
std::string host_;
|
||||
std::string port_;
|
||||
std::unique_ptr<network_asio::connection> conn_;
|
||||
std::unique_ptr<gui2::dialogs::network_transmission> stat_;
|
||||
std::string last_error_;
|
||||
std::string last_error_data_;
|
||||
|
||||
|
@ -73,11 +73,6 @@ network_transmission::network_transmission(
|
||||
set_restore(true);
|
||||
}
|
||||
|
||||
void network_transmission::set_subtitle(const std::string& subtitle)
|
||||
{
|
||||
subtitle_ = subtitle;
|
||||
}
|
||||
|
||||
void network_transmission::pre_show(window& window)
|
||||
{
|
||||
// ***** ***** ***** ***** Set up the widgets ***** ***** ***** *****
|
||||
@ -94,7 +89,10 @@ void network_transmission::pre_show(window& window)
|
||||
void network_transmission::post_show(window& /*window*/)
|
||||
{
|
||||
pump_monitor_.window_.reset();
|
||||
connection_->cancel();
|
||||
|
||||
if(get_retval() == window::retval::CANCEL) {
|
||||
connection_->cancel();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
|
@ -69,12 +69,6 @@ public:
|
||||
const std::string& title,
|
||||
const std::string& subtitle);
|
||||
|
||||
void set_subtitle(const std::string&);
|
||||
void set_connection_data(connection_data& connection)
|
||||
{
|
||||
connection_ = &connection;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Inherited from modal_dialog. */
|
||||
virtual void pre_show(window& window) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user