set _ptr to nullptr after reset()

This commit is contained in:
tastytea 2018-05-28 15:46:38 +02:00
parent 50d3ab6bba
commit a1ef65b71c
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon project (expandurl-mastodon
VERSION 0.8.1 VERSION 0.8.2
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -85,9 +85,10 @@ const void Listener::read_config()
const void Listener::start() const void Listener::start()
{ {
static std::uint_fast16_t ret = 0; static std::uint_fast16_t ret;
_thread = std::thread([=] _thread = std::thread([=]
{ {
ret = 0;
_running = true; _running = true;
Easy masto(_instance, _access_token); Easy masto(_instance, _access_token);
masto.set_useragent(static_cast<const string>("expandurl-mastodon/") + masto.set_useragent(static_cast<const string>("expandurl-mastodon/") +
@ -103,7 +104,7 @@ const void Listener::start()
} }
_running = false; _running = false;
}); });
while (_ptr == nullptr) while (!_ptr)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
} }
@ -125,6 +126,7 @@ const void Listener::stop()
_ptr->cancel_stream(); _ptr->cancel_stream();
_thread.join(); _thread.join();
_ptr.reset(); _ptr.reset();
_ptr = nullptr;
_stream = ""; _stream = "";
} }
else else