1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 12:53:51 +00:00

Store UdpListen instance in an unique ptr.

This commit is contained in:
Bartosz Taudul 2019-08-29 18:36:55 +02:00
parent 5e8b2a0723
commit adfc4eb59b

View File

@ -254,7 +254,7 @@ int main( int argc, char** argv )
char addr[1024] = { "127.0.0.1" }; char addr[1024] = { "127.0.0.1" };
std::thread loadThread; std::thread loadThread;
tracy::UdpListen* broadcastListen = nullptr; std::unique_ptr<tracy::UdpListen> broadcastListen;
enum class ViewShutdown { False, True, Join }; enum class ViewShutdown { False, True, Join };
ViewShutdown viewShutdown = ViewShutdown::False; ViewShutdown viewShutdown = ViewShutdown::False;
@ -295,11 +295,10 @@ int main( int argc, char** argv )
const auto time = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count(); const auto time = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count();
if( !broadcastListen ) if( !broadcastListen )
{ {
broadcastListen = new tracy::UdpListen(); broadcastListen = std::make_unique<tracy::UdpListen>();
if( !broadcastListen->Listen( 8086 ) ) if( !broadcastListen->Listen( 8086 ) )
{ {
delete broadcastListen; broadcastListen.reset();
broadcastListen = nullptr;
} }
} }
else else
@ -560,8 +559,7 @@ int main( int argc, char** argv )
{ {
if( broadcastListen ) if( broadcastListen )
{ {
delete broadcastListen; broadcastListen.reset();
broadcastListen = nullptr;
clients.clear(); clients.clear();
} }
if( loadThread.joinable() ) loadThread.join(); if( loadThread.joinable() ) loadThread.join();