From b6fffb39235ba522258f68eac2ec55388592933a Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 28 Dec 2023 17:42:39 +0000 Subject: [PATCH] Add more tool stack tracing --- common/tool/tool_event.cpp | 13 ++++++++++++- common/tool/tool_interactive.cpp | 8 ++++++++ common/tool/tool_manager.cpp | 7 +++++++ include/tool/tool_event.h | 8 ++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index a2bd1182e3..e8c07dd442 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -163,7 +163,7 @@ const std::string TOOL_EVENT::Format() const } else { - ev += "none"; + ev += "none "; } if( m_actions & TA_MOUSE ) @@ -195,6 +195,17 @@ const std::string TOOL_EVENT_LIST::Format() const } +const std::string TOOL_EVENT_LIST::Names() const +{ + std::string s; + + for( const TOOL_EVENT& e : m_events ) + s += e.m_commandStr + " "; + + return s; +} + + bool TOOL_EVENT::IsClick( int aButtonMask ) const { return ( m_actions & TA_MOUSE_CLICK ) && ( m_mouseButtons & aButtonMask ) == m_mouseButtons; diff --git a/common/tool/tool_interactive.cpp b/common/tool/tool_interactive.cpp index efaecb9b19..7224db6480 100644 --- a/common/tool/tool_interactive.cpp +++ b/common/tool/tool_interactive.cpp @@ -24,11 +24,15 @@ #include +#include + #include #include #include #include +#include + TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_BASE( INTERACTIVE, aId, aName ), m_menu( *this ) @@ -69,6 +73,10 @@ void TOOL_INTERACTIVE::resetTransitions() void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions ) { + wxLogTrace( kicadTraceToolStack, + wxS( "TOOL_INTERACTIVE::goInternal: Tool '%s', Registering handler for actions '%s'" ), + GetName(), aConditions.Names() ); + m_toolMgr->ScheduleNextState( this, aState, aConditions ); } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index a77230eeec..fed94052a2 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -245,6 +245,9 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(), wxT( "Adding two tools of the same type may result in unexpected behavior.") ); + wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::RegisterTool: Registering tool %s with ID %d" ), + aTool->GetName(), aTool->GetId() ); + m_toolOrder.push_back( aTool ); TOOL_STATE* st = new TOOL_STATE( aTool ); @@ -612,6 +615,10 @@ void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason ) for( auto& state : m_toolState ) { TOOL_BASE* tool = state.first; + + wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::ResetTools: Resetting tool '%s'" ), + tool->GetName() ); + setActiveState( state.second ); tool->Reset( aReason ); diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index dba8badee3..4ff93b9e05 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -535,6 +535,7 @@ public: bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const; private: + friend class TOOL_EVENT_LIST; friend class TOOL_DISPATCHER; friend class TOOL_MANAGER; friend class TOOLS_HOLDER; @@ -665,6 +666,13 @@ public: */ const std::string Format() const; + /** + * Returns a string containing the names of all the events in this list. + * + * @return Event names. + */ + const std::string Names() const; + OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const { for( const TOOL_EVENT& event : m_events )