diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 31f96ec856..fccac45df6 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -173,7 +173,7 @@ bool EE_SELECTION_TOOL::Init() if( m_isSymbolEditor || m_isSymbolViewer ) return false; - return ( E_C::Empty( aSel ) || sheetSelection( aSel ) ); + return E_C::LessThan( 2 )( aSel ) && E_C::OnlyType( SCH_SHEET_T )( aSel ); }; auto schEditCondition = diff --git a/include/tool/selection_conditions.h b/include/tool/selection_conditions.h index e804f8498f..fc68aa1b4b 100644 --- a/include/tool/selection_conditions.h +++ b/include/tool/selection_conditions.h @@ -41,6 +41,7 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, const SELECTION_CONDITION& aConditionB ); +SELECTION_CONDITION operator!( const SELECTION_CONDITION& aCondition ); /// Signature for a reference to a function that takes a SELECTION and returns @@ -61,6 +62,15 @@ SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( SELECTION_BOOL aConditionA, const SELECTION_CONDITION& aConditionB ); +// We don't use uninitialized SELECTION_CONDITIONs, so casting to bool is probably +// a programming error. +template<> SELECTION_CONDITION::operator bool() const noexcept +{ + wxASSERT( "Incorrect use of SELECTION_CONDITION" ); + return false; +}; + + /** * Class that groups generic conditions for selected items. */