diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-07 06:44:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-07 06:44:38 +0300 |
commit | fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff (patch) | |
tree | fa68e8d59ade869c1de33bce9eb60a8cd05fdbc8 /src/gui | |
parent | ba0d8f949647aa4ced776438a1e1e9ebd77c4660 (diff) | |
download | mv-fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff.tar.gz mv-fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff.tar.bz2 mv-fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff.tar.xz mv-fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff.zip |
Fix possible thread structure memory leak on SDL2 if thread terminated before cleanup.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/whoisonline.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 1401ec280..35d930c4c 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -175,9 +175,8 @@ WhoIsOnline::~WhoIsOnline() config.removeListeners(this); CHECKLISTENERS - if ((mThread != nullptr) && (SDL_GetThreadID(mThread) != 0u)) - SDL_WaitThread(mThread, nullptr); - + SDL::WaitThread(mThread); + mThread = nullptr; free(mMemoryBuffer); mMemoryBuffer = nullptr; @@ -628,9 +627,8 @@ void WhoIsOnline::download() else if (mWebList) { mDownloadComplete = true; - if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U) - SDL_WaitThread(mThread, nullptr); - + SDL::WaitThread(mThread); + mThread = nullptr; mDownloadComplete = false; mThread = SDL::createThread(&WhoIsOnline::downloadThread, "whoisonline", this); @@ -729,11 +727,8 @@ void WhoIsOnline::action(const ActionEvent &event) mUpdateButton->setEnabled(false); // TRANSLATORS: who is online window name setCaption(_("Who Is Online - Update")); - if (mThread != nullptr && SDL_GetThreadID(mThread) != 0U) - { - SDL_WaitThread(mThread, nullptr); - mThread = nullptr; - } + SDL::WaitThread(mThread); + mThread = nullptr; mDownloadComplete = true; } } |