Reset current category marker if deleted wxPG property is a category property.
If deleted category or its sub-category is a current category then reset current category marker. See #16617. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78112 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1926,6 +1926,31 @@ void wxPropertyGridPageState::DoInvalidateChildrenNames(wxPGProperty* p,
|
||||
}
|
||||
}
|
||||
|
||||
bool wxPropertyGridPageState::IsChildCategory(wxPGProperty* p,
|
||||
wxPropertyCategory* cat,
|
||||
bool recursive)
|
||||
{
|
||||
if (p->IsCategory())
|
||||
{
|
||||
for( unsigned int i = 0; i < p->GetChildCount(); i++ )
|
||||
{
|
||||
wxPGProperty* child = p->Item(i);
|
||||
|
||||
if (child->IsCategory() && child == cat)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( recursive && IsChildCategory(child, cat, recursive) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
{
|
||||
wxCHECK_RET( item->GetParent(),
|
||||
@@ -1963,6 +1988,16 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
||||
}
|
||||
|
||||
// If deleted category or its sub-category is
|
||||
// a current category then reset current category marker.
|
||||
if ( item->IsCategory() )
|
||||
{
|
||||
if (item == m_currentCategory || IsChildCategory(item, m_currentCategory, true))
|
||||
{
|
||||
m_currentCategory = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Must defer deletion? Yes, if handling a wxPG event.
|
||||
if ( pg && pg->m_processedEvent )
|
||||
{
|
||||
@@ -1994,6 +2029,9 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
// Otherwise crash can happen.
|
||||
wxASSERT_MSG( !DoIsPropertySelected(item) && !item->IsChildSelected(true),
|
||||
wxT("Failed to unselect deleted property") );
|
||||
// Don't attempt to delete current category.
|
||||
wxASSERT_MSG( !item->IsCategory() || item != m_currentCategory,
|
||||
wxT("Current category cannot be deleted") );
|
||||
|
||||
// Prevent property and its children from being re-selected
|
||||
item->SetFlag(wxPG_PROP_BEING_DELETED);
|
||||
@@ -2001,18 +2039,10 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
|
||||
unsigned int indinparent = item->GetIndexInParent();
|
||||
|
||||
wxPGProperty* pwc = (wxPGProperty*)item;
|
||||
|
||||
// Delete children
|
||||
if ( item->GetChildCount() && !item->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||
{
|
||||
// deleting a category
|
||||
if ( item->IsCategory() )
|
||||
{
|
||||
if ( pwc == m_currentCategory )
|
||||
m_currentCategory = NULL;
|
||||
}
|
||||
|
||||
item->DeleteChildren();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user