diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-09-21 12:08:32 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-09-21 12:08:32 +0000 |
commit | 592ce6b7d0a79f30f6741d30e2f473f74c882a48 (patch) | |
tree | b0565035b42a120960e6fc667cf9f3521893f886 /src | |
parent | edc8acb22df82a5cec4cd5ffac0f81be053c6ec5 (diff) | |
download | mana-592ce6b7d0a79f30f6741d30e2f473f74c882a48.tar.gz mana-592ce6b7d0a79f30f6741d30e2f473f74c882a48.tar.bz2 mana-592ce6b7d0a79f30f6741d30e2f473f74c882a48.tar.xz mana-592ce6b7d0a79f30f6741d30e2f473f74c882a48.zip |
Made canceling the update process non-blocking (Patch by VictorSan)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/updatewindow.cpp | 18 | ||||
-rw-r--r-- | src/gui/updatewindow.h | 5 |
2 files changed, 19 insertions, 4 deletions
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; |