diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 878e9845f1..96e8055d2f 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -285,7 +285,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName ) } -bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* aParam ) +bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, std::any aParam ) { TOOL_ACTION* action = m_actionMgr->FindAction( aActionName ); @@ -319,7 +319,7 @@ VECTOR2D TOOL_MANAGER::GetCursorPosition() const } -bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam ) +bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, std::any aParam ) { if( m_shuttingDown ) return true; @@ -331,7 +331,7 @@ bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara event.SetMousePosition( GetCursorPosition() ); // Allow to override the action parameter - if( aParam ) + if( aParam.has_value() ) event.SetParameter( aParam ); if( aNow ) diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index f15df6a49a..26857c6c74 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -138,17 +138,14 @@ public: * depends on the action. * @return False if the action was not found. */ - template - bool RunAction( const std::string& aActionName, bool aNow = false, T aParam = NULL ) - { - return RunAction( aActionName, aNow, reinterpret_cast( aParam ) ); - } - - bool RunAction( const std::string& aActionName, bool aNow, void* aParam ); + bool RunAction( const std::string& aActionName, bool aNow, std::any aParam ); bool RunAction( const std::string& aActionName, bool aNow = false ) { - return RunAction( aActionName, aNow, (void*) NULL ); + // Default initialize the parameter argument to an empty std::any + std::any a; + + return RunAction( aActionName, aNow, a ); } /** @@ -164,17 +161,14 @@ public: * depends on the action. * @return True if the action was handled immediately */ - template - bool RunAction( const TOOL_ACTION& aAction, bool aNow = false, T aParam = NULL ) - { - return RunAction( aAction, aNow, reinterpret_cast( aParam ) ); - } - - bool RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam ); + bool RunAction( const TOOL_ACTION& aAction, bool aNow, std::any aParam ); bool RunAction( const TOOL_ACTION& aAction, bool aNow = false ) { - return RunAction( aAction, aNow, (void*) NULL ); + // Default initialize the parameter argument to an empty std::any + std::any a; + + return RunAction( aAction, aNow, a ); } /**