From 24820a5a672cc1472a8600791e6aa9b4ba98d5c6 Mon Sep 17 00:00:00 2001 From: Anil Date: Tue, 10 Jul 2018 11:31:54 +0530 Subject: [PATCH] Invalidate "hover" column index in wxHeaderCtrl if necessary Don't leave "m_hover" invalid if the number of columns in wxHeaderCtrl is reduced, as this would result in a crash later when it is used. This notably fixes a crash after removing the last column from generic wxDataViewCtrl. Closes https://github.com/wxWidgets/wxWidgets/pull/852 --- src/generic/headerctrlg.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index e723d677b3..7382fb47ad 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -93,6 +93,11 @@ void wxHeaderCtrl::DoSetCount(unsigned int count) m_numColumns = count; + // don't leave the column index invalid, this would cause a crash later if + // it is used from OnMouse() + if ( m_hover >= count ) + m_hover = COL_NONE; + InvalidateBestSize(); Refresh(); }