Do not mark selected wxPG property as 'being deleted'.

Only unselected wxPG property can be marked as 'being deleted'.
If this is done for selected wxGP property then in some circumstances it cannot be unselected and hence cannot be safely deleted.

See #16617.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78091 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek 2014-11-04 19:23:01 +00:00
parent 642528bf5e
commit d6e23dd99b

View File

@ -1914,6 +1914,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
wxPropertyGrid* pg = GetGrid();
// Try to unselect property and its subproperties.
if ( DoIsPropertySelected(item) )
{
if ( pg && pg->GetState() == this )
@ -1933,10 +1934,6 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
}
// Prevent property and its children from being re-selected
item->SetFlag(wxPG_PROP_BEING_DELETED);
DoMarkChildrenAsDeleted(item, true);
// Must defer deletion? Yes, if handling a wxPG event.
if ( pg && pg->m_processedEvent )
{
@ -1970,6 +1967,15 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
return;
}
// Property has to be unselected prior deleting.
// Otherwise crash can happen.
wxASSERT_MSG( !DoIsPropertySelected(item) && !item->IsChildSelected(true),
wxT("Failed to unselect deleted property") );
// Prevent property and its children from being re-selected
item->SetFlag(wxPG_PROP_BEING_DELETED);
DoMarkChildrenAsDeleted(item, true);
unsigned int indinparent = item->GetIndexInParent();
wxPGProperty* pwc = (wxPGProperty*)item;