From a6deabaeee960afd6cf9c15152f3acef756a229d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 8 Mar 2020 15:02:20 +0100 Subject: [PATCH] Allow port entry in address field. --- profiler/src/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 9af6c431..b6923432 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -541,7 +541,8 @@ static void DrawContents() connectClicked |= ImGui::Button( ICON_FA_WIFI " Connect" ); if( connectClicked && *addr && !loadThread.joinable() ) { - std::string addrStr( addr ); + const auto addrLen = strlen( addr ); + std::string addrStr( addr, addr+addrLen ); auto it = connHistMap.find( addrStr ); if( it != connHistMap.end() ) { @@ -553,7 +554,18 @@ static void DrawContents() } connHistVec = RebuildConnectionHistory( connHistMap ); - view = std::make_unique( addr, port, fixedWidth, smallFont, bigFont, SetWindowTitleCallback ); + auto ptr = addr + addrLen - 1; + while( ptr > addr && *ptr != ':' ) ptr--; + if( *ptr == ':' ) + { + std::string addrPart = std::string( addr, ptr ); + uint32_t portPart = atoi( ptr+1 ); + view = std::make_unique( addrPart.c_str(), portPart, fixedWidth, smallFont, bigFont, SetWindowTitleCallback ); + } + else + { + view = std::make_unique( addr, port, fixedWidth, smallFont, bigFont, SetWindowTitleCallback ); + } } ImGui::SameLine( 0, ImGui::GetFontSize() * 2 ); if( ImGui::Button( ICON_FA_FOLDER_OPEN " Open saved trace" ) && !loadThread.joinable() )