From 44dc3e20dfb2625728e5855f703637d49ed53ff4 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 15 Feb 2015 22:21:56 +0000 Subject: [PATCH] Prevent sending wxEVT_PG_LABEL_EDIT_ENDING events recursively. By preventing sending wxEVT_PG_LABEL_EDIT_ENDING events recursively (recursive generation can happen due to the calling wxPropertyGrid::RefreshProperty() directly or indirectly from within wxEVT_PG_LABEL_EDIT_ENDING event handler) spurious events are not sent to the application and wxPropertyGrid::DoEndLabelEdit() function is not reentered. Closes #16864. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78500 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/propgrid.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 4dfc0cc707..a92de53b71 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -1072,8 +1072,20 @@ void wxPropertyGrid::DoEndLabelEdit( bool commit, int selFlags ) if ( commit ) { + const int labelColIdx = m_selColumn; + if ( !(selFlags & wxPG_SEL_DONT_SEND_EVENT) ) { + // Don't send wxEVT_PG_LABEL_EDIT_ENDING event recursively + // for the same property and the same label. + if ( m_processedEvent && + m_processedEvent->GetEventType() == wxEVT_PG_LABEL_EDIT_ENDING && + m_processedEvent->GetProperty() == prop && + m_processedEvent->GetColumn() == m_selColumn) + { + return; + } + // wxPG_SEL_NOVALIDATE is passed correctly in selFlags if ( SendEvent( wxEVT_PG_LABEL_EDIT_ENDING, prop, NULL, selFlags, @@ -1083,16 +1095,16 @@ void wxPropertyGrid::DoEndLabelEdit( bool commit, int selFlags ) wxString text = m_labelEditor->GetValue(); wxPGCell* cell = NULL; - if ( prop->HasCell(m_selColumn) ) + if ( prop->HasCell(labelColIdx) ) { - cell = &prop->GetCell(m_selColumn); + cell = &prop->GetCell(labelColIdx); } else { - if ( m_selColumn == 0 ) + if ( labelColIdx == 0 ) prop->SetLabel(text); else - cell = &prop->GetOrCreateCell(m_selColumn); + cell = &prop->GetOrCreateCell(labelColIdx); } if ( cell )