From baf67986957afc3b4c47ed6f3def0ba3af76d2e9 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 29 Jul 2021 23:17:41 +0100 Subject: [PATCH] Check for column existence before checking for tooltip enabled Otherwise we try to read a bitset at location -1, which triggers and assert on MSVC. Fixes https://gitlab.com/kicad/code/kicad/issues/8890 --- common/grid_tricks.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index 39314cb0c2..cf01e0e14c 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -180,17 +180,10 @@ void GRID_TRICKS::onGridMotion( wxMouseEvent& aEvent ) wxPoint pos = m_grid->CalcScrolledPosition( wxPoint( pt.x, pt.y ) ); int col = m_grid->XToCol( pos.x ); - - // Skip the event if the tooltip shouldn't be shown - if( !m_tooltipEnabled[col] || ( col == wxNOT_FOUND ) ) - { - m_grid->GetGridWindow()->SetToolTip( "" ); - return; - } - int row = m_grid->YToRow( pos.y ); - if( row == wxNOT_FOUND ) + // Empty tooltip if the cell doesn't exist or the column doesn't have tooltips + if( ( col == wxNOT_FOUND ) || ( row == wxNOT_FOUND ) || !m_tooltipEnabled[col] ) { m_grid->GetGridWindow()->SetToolTip( "" ); return;