From 8785dfe316e1e3f7a0cfa9d099e887f88986a709 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 2 Jun 2017 12:26:08 +0200 Subject: [PATCH] [Download] Fix memory leaks --- src/Components/Modules/Discovery.cpp | 2 -- src/Components/Modules/Download.cpp | 12 ++++++------ src/Components/Modules/IPCPipe.cpp | 2 -- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 2e4fa8c0..633dd8aa 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -109,7 +109,5 @@ namespace Components { Discovery::Thread.join(); } - - Discovery::Thread = std::thread(); } } diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 0fc228e5..593e5ecf 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -828,12 +828,6 @@ namespace Components Download::~Download() { - Download::Terminate = true; - if (Download::ServerThread.joinable()) - { - Download::ServerThread.join(); - } - if (Dedicated::IsEnabled()) { mg_mgr_free(&Download::Mgr); @@ -842,6 +836,12 @@ namespace Components void Download::preDestroy() { + Download::Terminate = true; + if (Download::ServerThread.joinable()) + { + Download::ServerThread.join(); + } + if (!Dedicated::IsEnabled()) { Download::CLDownload.clear(); diff --git a/src/Components/Modules/IPCPipe.cpp b/src/Components/Modules/IPCPipe.cpp index 57346dcc..9fe6b2a8 100644 --- a/src/Components/Modules/IPCPipe.cpp +++ b/src/Components/Modules/IPCPipe.cpp @@ -129,8 +129,6 @@ namespace Components Logger::Print("Pipe thread terminated.\n"); } - - this->thread = std::thread(); } void Pipe::setName(std::string name)