From 3c22134f7840ddbd72bd9b92c59ba3774396313e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 6 Mar 2020 22:11:29 +0100 Subject: [PATCH] Reconnect to client, if requested. --- profiler/src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 2d77345a..08215fc4 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -359,6 +359,10 @@ int main( int argc, char** argv ) static void DrawContents() { + static bool reconnect = false; + static std::string reconnectAddr; + static int reconnectPort; + const ImVec4 clear_color = ImColor( 114, 144, 154 ); int display_w, display_h; @@ -660,6 +664,12 @@ static void DrawContents() if( !view->Draw() ) { viewShutdown = ViewShutdown::True; + reconnect = view->ReconnectRequested(); + if( reconnect ) + { + reconnectAddr = view->GetAddress(); + reconnectPort = view->GetPort(); + } loadThread = std::thread( [view = std::move( view )] () mutable { view.reset(); viewShutdown = ViewShutdown::Join; @@ -747,6 +757,10 @@ static void DrawContents() case ViewShutdown::Join: loadThread.join(); viewShutdown = ViewShutdown::False; + if( reconnect ) + { + view = std::make_unique( reconnectAddr.c_str(), reconnectPort, fixedWidth, smallFont, bigFont, SetWindowTitleCallback ); + } break; default: break;