summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/serverdialog.cpp5
-rw-r--r--src/net/download.cpp15
2 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index f47f33ea..e97eb099 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -192,6 +192,7 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
else
{
+ mDownload->cancel();
mQuitButton->setEnabled(false);
mConnectButton->setEnabled(false);
@@ -234,6 +235,7 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "quit")
{
+ mDownload->cancel();
state = STATE_FORCE_QUIT;
}
else if (event.getId() == "addEntry")
@@ -401,6 +403,9 @@ void ServerDialog::loadServers()
int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,
size_t total, size_t remaining)
{
+ if (status == DOWNLOAD_STATUS_CANCELLED)
+ return -1;
+
ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr);
bool finished = false;
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 061cecfd..8a5e0828 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -215,6 +215,9 @@ int Download::downloadThread(void *ptr)
{
switch (res)
{
+ case CURLE_ABORTED_BY_CALLBACK:
+ d->mOptions.cancel = true;
+ break;
case CURLE_COULDNT_CONNECT:
default:
logger->log("curl error %d: %s host: %s",
@@ -222,6 +225,11 @@ int Download::downloadThread(void *ptr)
break;
}
+ if (d->mOptions.cancel)
+ {
+ break;
+ }
+
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0);
if (!d->mOptions.memoryWrite)
@@ -280,7 +288,11 @@ int Download::downloadThread(void *ptr)
attempts++;
}
- if (!complete) {
+ if (d->mOptions.cancel)
+ {
+ // Nothing to do...
+ }
+ else if (!complete || attempts >= 3) {
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_ERROR, 0, 0);
}
else
@@ -291,5 +303,4 @@ int Download::downloadThread(void *ptr)
return 0;
}
-
} // namespace Net