Better safety around boost::optional.

I'm not sure these are necessary but I got a crash when checking one
as a boolean instead of calling is_initialized().  Sadly, my debugger
doesn't like boost, so I didn't get much more info.
This commit is contained in:
Jeff Young 2019-07-04 14:19:08 +01:00
parent eeae94b4b6
commit 29df4f809e
1 changed files with 13 additions and 20 deletions

View File

@ -185,13 +185,11 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
bool TOOL_EVENT::IsCancelInteractive() bool TOOL_EVENT::IsCancelInteractive()
{ {
if( GetCommandStr() && GetCommandStr().get() == ACTIONS::cancelInteractive.GetName() ) return( ( m_commandStr.is_initialized()
return true; && m_commandStr.get() == ACTIONS::cancelInteractive.GetName() )
|| ( m_commandId.is_initialized()
if( GetCommandId() && GetCommandId().get() == ACTIONS::cancelInteractive.GetId() ) && m_commandId.get() == ACTIONS::cancelInteractive.GetId() )
return true; || ( m_actions == TA_CANCEL_TOOL ) );
return IsCancel();
} }
@ -205,20 +203,15 @@ bool TOOL_EVENT::IsSelectionEvent()
bool TOOL_EVENT::IsPointEditor() bool TOOL_EVENT::IsPointEditor()
{ {
if( GetCommandStr() && GetCommandStr().get().find( "PointEditor" ) != GetCommandStr()->npos ) return( ( m_commandStr.is_initialized()
return true; && m_commandStr.get().find( "PointEditor" ) != GetCommandStr()->npos )
|| ( m_commandId.is_initialized()
if( GetCommandId() && GetCommandId() == ACTIONS::activatePointEditor.GetId() ) && m_commandId.get() == ACTIONS::activatePointEditor.GetId() ) );
return true;
return false;
} }
bool TOOL_EVENT::IsMoveTool() bool TOOL_EVENT::IsMoveTool()
{ {
if( GetCommandStr() && GetCommandStr().get().find( "InteractiveMove" ) != GetCommandStr()->npos ) return( m_commandStr.is_initialized()
return true; && m_commandStr.get().find( "InteractiveMove" ) != GetCommandStr()->npos );
return false;
} }