mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Trim address entry field.
Sometimes a stray whitespace may be inserted in the address field, for example when copying and pasting from somewhere else.
This commit is contained in:
parent
5795bc5766
commit
d46eebf794
@ -65,17 +65,16 @@ void ConnectionHistory::Rebuild()
|
|||||||
std::swap( m_connHistVec, vec );
|
std::swap( m_connHistVec, vec );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionHistory::Count( const char* name )
|
void ConnectionHistory::Count( const std::string& name )
|
||||||
{
|
{
|
||||||
std::string addr( name );
|
auto it = m_connHistMap.find( name );
|
||||||
auto it = m_connHistMap.find( addr );
|
|
||||||
if( it != m_connHistMap.end() )
|
if( it != m_connHistMap.end() )
|
||||||
{
|
{
|
||||||
it->second++;
|
it->second++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_connHistMap.emplace( std::move( addr ), 1 );
|
m_connHistMap.emplace( name, 1 );
|
||||||
}
|
}
|
||||||
Rebuild();
|
Rebuild();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public:
|
|||||||
|
|
||||||
const std::string& Name( size_t idx ) const { return m_connHistVec[idx]->first; }
|
const std::string& Name( size_t idx ) const { return m_connHistVec[idx]->first; }
|
||||||
|
|
||||||
void Count( const char* name );
|
void Count( const std::string& name );
|
||||||
void Erase( size_t idx );
|
void Erase( size_t idx );
|
||||||
|
|
||||||
bool empty() const { return m_connHistVec.empty(); }
|
bool empty() const { return m_connHistVec.empty(); }
|
||||||
|
@ -967,20 +967,29 @@ static void DrawContents()
|
|||||||
connectClicked |= ImGui::Button( ICON_FA_WIFI " Connect" );
|
connectClicked |= ImGui::Button( ICON_FA_WIFI " Connect" );
|
||||||
if( connectClicked && *addr && !loadThread.joinable() )
|
if( connectClicked && *addr && !loadThread.joinable() )
|
||||||
{
|
{
|
||||||
connHist->Count( addr );
|
auto aptr = addr;
|
||||||
|
while( *aptr == ' ' || *aptr == '\t' ) aptr++;
|
||||||
|
auto aend = aptr;
|
||||||
|
while( *aend && *aend != ' ' && *aend != '\t' ) aend++;
|
||||||
|
|
||||||
const auto addrLen = strlen( addr );
|
if( aptr != aend )
|
||||||
auto ptr = addr + addrLen - 1;
|
{
|
||||||
while( ptr > addr && *ptr != ':' ) ptr--;
|
std::string address( aptr, aend );
|
||||||
|
connHist->Count( address );
|
||||||
|
|
||||||
|
auto adata = address.data();
|
||||||
|
auto ptr = adata + address.size() - 1;
|
||||||
|
while( ptr > adata && *ptr != ':' ) ptr--;
|
||||||
if( *ptr == ':' )
|
if( *ptr == ':' )
|
||||||
{
|
{
|
||||||
std::string addrPart = std::string( addr, ptr );
|
std::string addrPart = std::string( adata, ptr );
|
||||||
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, s_achievements );
|
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, s_achievements );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, s_achievements );
|
view = std::make_unique<tracy::View>( RunOnMainThread, address.c_str(), port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, s_achievements );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( s_config.memoryLimit )
|
if( s_config.memoryLimit )
|
||||||
|
Loading…
Reference in New Issue
Block a user