Don't fire event-parameter asserts when looking for a click event.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/KICAD-2CK
This commit is contained in:
Jeff Young 2023-10-13 20:30:43 +01:00
parent 0b06a1376b
commit 2bc273f8bc
3 changed files with 16 additions and 14 deletions

View File

@ -456,13 +456,13 @@ public:
/**
* Return a parameter assigned to the event. Its meaning depends on the target tool.
*/
template<typename T,
std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
T Parameter() const
{
T param;
wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with no parameter." );
wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with "
"no parameter." );
try
{
@ -470,9 +470,10 @@ public:
}
catch( const std::bad_any_cast& )
{
wxCHECK_MSG( false, T(),
wxString::Format( "Requested parameter type %s from event with parameter type %s.",
typeid(T).name(), m_param.type().name() ) );
wxCHECK_MSG( false, T(), wxString::Format( "Requested parameter type %s from event "
"with parameter type %s.",
typeid(T).name(),
m_param.type().name() ) );
}
return param;
@ -481,13 +482,13 @@ public:
/**
* Return pointer parameter assigned to the event. Its meaning depends on the target tool.
*/
template<typename T,
std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
T Parameter() const
{
T param = nullptr;
wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with no parameter." );
wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with "
"no parameter." );
try
{
@ -495,9 +496,10 @@ public:
}
catch( const std::bad_any_cast& )
{
wxCHECK_MSG( false, param,
wxString::Format( "Requested parameter type %s from event with parameter type %s.",
typeid(T).name(), m_param.type().name() ) );
wxCHECK_MSG( false, param, wxString::Format( "Requested parameter type %s from event "
"with parameter type %s.",
typeid(T).name(),
m_param.type().name() ) );
}
return param;

View File

@ -784,7 +784,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
|| evt->IsDblClick( BUT_LEFT ) )
{
// Eat mouse-up/-click events that leaked through from the lock dialog
if( eatFirstMouseUp && evt->Parameter<ACTIONS::CURSOR_EVENT_TYPE>() != ACTIONS::CURSOR_CLICK )
if( eatFirstMouseUp && !evt->IsAction( &ACTIONS::cursorClick ) )
{
eatFirstMouseUp = false;
continue;

View File

@ -714,7 +714,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) || isSkip )
{
// Eat mouse-up/-click events that leaked through from the lock dialog
if( eatFirstMouseUp && evt->Parameter<ACTIONS::CURSOR_EVENT_TYPE>() != ACTIONS::CURSOR_CLICK )
if( eatFirstMouseUp && !evt->IsAction( &ACTIONS::cursorClick ) )
{
eatFirstMouseUp = false;
continue;