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:
@@ -714,6 +714,10 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive);
|
void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive);
|
||||||
|
|
||||||
|
/** Check if property contains given sub-category */
|
||||||
|
bool IsChildCategory(wxPGProperty* p,
|
||||||
|
wxPropertyCategory* cat, bool recursive);
|
||||||
|
|
||||||
/** If visible, then this is pointer to wxPropertyGrid.
|
/** If visible, then this is pointer to wxPropertyGrid.
|
||||||
This shall *never* be NULL to indicate that this state is not visible.
|
This shall *never* be NULL to indicate that this state is not visible.
|
||||||
*/
|
*/
|
||||||
|
@@ -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 )
|
void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( item->GetParent(),
|
wxCHECK_RET( item->GetParent(),
|
||||||
@@ -1963,6 +1988,16 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
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.
|
// Must defer deletion? Yes, if handling a wxPG event.
|
||||||
if ( pg && pg->m_processedEvent )
|
if ( pg && pg->m_processedEvent )
|
||||||
{
|
{
|
||||||
@@ -1994,6 +2029,9 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
// Otherwise crash can happen.
|
// Otherwise crash can happen.
|
||||||
wxASSERT_MSG( !DoIsPropertySelected(item) && !item->IsChildSelected(true),
|
wxASSERT_MSG( !DoIsPropertySelected(item) && !item->IsChildSelected(true),
|
||||||
wxT("Failed to unselect deleted property") );
|
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
|
// Prevent property and its children from being re-selected
|
||||||
item->SetFlag(wxPG_PROP_BEING_DELETED);
|
item->SetFlag(wxPG_PROP_BEING_DELETED);
|
||||||
@@ -2001,18 +2039,10 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
|
|
||||||
unsigned int indinparent = item->GetIndexInParent();
|
unsigned int indinparent = item->GetIndexInParent();
|
||||||
|
|
||||||
wxPGProperty* pwc = (wxPGProperty*)item;
|
|
||||||
|
|
||||||
// Delete children
|
// Delete children
|
||||||
if ( item->GetChildCount() && !item->HasFlag(wxPG_PROP_AGGREGATE) )
|
if ( item->GetChildCount() && !item->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||||
{
|
{
|
||||||
// deleting a category
|
// deleting a category
|
||||||
if ( item->IsCategory() )
|
|
||||||
{
|
|
||||||
if ( pwc == m_currentCategory )
|
|
||||||
m_currentCategory = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->DeleteChildren();
|
item->DeleteChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user