From fec0a38e6a12c8674e54a29b0c3ae54fa78e86ff Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 7 Sep 2017 06:44:38 +0300 Subject: Fix possible thread structure memory leak on SDL2 if thread terminated before cleanup. --- src/gui/windows/whoisonline.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/gui') 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; } } -- cgit v1.2.3-60-g2f50