Nullptr safety to attempt to prevent Sentry crash.

https://sentry.io/organizations/kicad/issues/3712084175
This commit is contained in:
Jeff Young 2022-12-12 10:42:51 +00:00
parent 5e8227b54a
commit 346530a5b1
1 changed files with 13 additions and 5 deletions

View File

@ -260,21 +260,29 @@ void HIERARCHY_NAVIG_PANEL::onSelectSheetPath( wxTreeEvent& aEvent )
void HIERARCHY_NAVIG_PANEL::onRightClick( wxTreeEvent& aEvent )
{
wxTreeItemId itemSel = m_tree->GetFocusedItem();
if( !itemSel.IsOk() )
return;
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
if( !itemData )
return;
wxMenu ctxMenu;
ctxMenu.Append( 1, _( "Edit Page Number" ) );
if( GetPopupMenuSelectionFromUser( ctxMenu ) == 1 )
{
wxTreeItemId itemSel = m_tree->GetSelection();
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
wxString msg;
wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false );
wxString pageNumber = itemData->m_SheetPath.GetPageNumber();
msg.Printf( _( "Enter page number for sheet path%s" ),
( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
msg.Printf( _( "Enter page number for sheet path %s" ),
( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " )
: sheetPath + wxT( ": " ) );
wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );