summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/updatewindow.cpp18
-rw-r--r--src/gui/updatewindow.h5
3 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b0ce1897..b7818eee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2006-09-21 Eugenio Favalli <elvenprogrammer@gmail.com>
* data/graphics/tiles/Makefile.am: Added missing tileset.
+ * src/gui/updatewindow.cpp, src/gui/updatewindow.h: Made canceling the
+ update process non-blocking (Patch by VictorSan).
2006-09-21 Philipp Sehmisch <tmw@crushnet.org>
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 654ecaaf..c8be462f 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -48,9 +48,9 @@ UpdaterWindow::UpdaterWindow():
Window("Updating..."),
mThread(NULL), mMutex(NULL), mDownloadStatus(UPDATE_NEWS),
mUpdateHost(""), mCurrentFile("news.txt"), mBasePath(""),
- mStoreInMemory(true), mDownloadComplete(true), mDownloadedBytes(0),
- mMemoryBuffer(NULL), mCurlError(new char[CURL_ERROR_SIZE]),
- mFileIndex(0)
+ mStoreInMemory(true), mDownloadComplete(true), mUserCancel(false),
+ mDownloadedBytes(0), mMemoryBuffer(NULL),
+ mCurlError(new char[CURL_ERROR_SIZE]), mFileIndex(0)
{
mCurlError[0] = 0;
@@ -133,6 +133,8 @@ void UpdaterWindow::action(const std::string& eventId, gcn::Widget* widget)
{
if (eventId == "cancel")
{
+ // Register the user cancel
+ mUserCancel=true;
// Skip the updating process
if (mDownloadStatus == UPDATE_COMPLETE)
{
@@ -329,7 +331,15 @@ void UpdaterWindow::logic()
case UPDATE_ERROR:
if (mThread)
{
- SDL_WaitThread(mThread, NULL);
+ if(mUserCancel){
+ // Kill the thread, because user has canceled
+ SDL_KillThread(mThread);
+ // Set the flag to false again
+ mUserCancel = false;
+ }
+ else{
+ SDL_WaitThread(mThread, NULL);
+ }
mThread = NULL;
}
addRow("");
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 8a168be8..5016036d 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -162,6 +162,11 @@ class UpdaterWindow : public Window, public gcn::ActionListener
bool mDownloadComplete;
/**
+ * Flag that show if the user has canceled the update
+ */
+ bool mUserCancel;
+
+ /**
* Byte count currently downloaded in mMemoryBuffer.
*/
int mDownloadedBytes;