diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-05 21:38:31 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-07 01:49:54 +0100 |
commit | d26abb724e4d64ca7be507d99d80ab778813684f (patch) | |
tree | 260f00ec675b38ea69ba085eaa7a8d61af2bc32b /src/gui/updatewindow.h | |
parent | c4680eb890064cd2491dfc578941c72fe1463a82 (diff) | |
download | mana-d26abb724e4d64ca7be507d99d80ab778813684f.tar.gz mana-d26abb724e4d64ca7be507d99d80ab778813684f.tar.bz2 mana-d26abb724e4d64ca7be507d99d80ab778813684f.tar.xz mana-d26abb724e4d64ca7be507d99d80ab778813684f.zip |
Fix race condition with a std::string access
The downloading thread was writing to a std::string while the main
thread was trying to draw it, for example. Now access to the label
caption is guarded with a mutex.
Should fix crashes while downloading updates.
(cherry picked from eAthena branch, commits
6ac9c3bce62a8fc79e23477417188108f0ad9fa6 and
06d0205bab253ec5d01e8483ab639a092fe117c5)
Diffstat (limited to 'src/gui/updatewindow.h')
-rw-r--r-- | src/gui/updatewindow.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index d7e3c4c7..a7dfe2cb 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -30,12 +30,13 @@ #include "../guichanfwd.h" +#include "../utils/mutex.h" + class BrowserBox; class Button; class ProgressBar; class ScrollArea; -struct SDL_mutex; struct SDL_Thread; /** @@ -88,7 +89,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener int updateState; - protected: +private: void download(); /** @@ -133,6 +134,12 @@ class UpdaterWindow : public Window, public gcn::ActionListener /** The file currently downloading. */ std::string mCurrentFile; + /** The new label caption to be set in the logic method. */ + std::string mNewLabelCaption; + + /** The mutex used to guard access to mNewLabelCaption. */ + Mutex mLabelMutex; + /** The Adler32 checksum of the file currently downloading. */ unsigned long mCurrentChecksum; @@ -164,7 +171,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener Button *mCancelButton; /**< Button to stop the update process. */ Button *mPlayButton; /**< Button to start playing. */ ProgressBar *mProgressBar; /**< Update progress bar. */ - BrowserBox* mBrowserBox; /**< Box to display news. */ + BrowserBox *mBrowserBox; /**< Box to display news. */ ScrollArea *mScrollArea; /**< Used to scroll news box. */ }; |