When wxPGProperty is un-attached from wxPropertyGrid, keep its 'default' cell references invalid/NULL (fixes #12552)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -306,6 +306,13 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used mostly internally to figure out if this cell is supposed
|
||||||
|
// to have default values when attached to a grid.
|
||||||
|
bool IsInvalid() const
|
||||||
|
{
|
||||||
|
return ( m_refData == NULL );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual wxObjectRefData *CreateRefData() const
|
virtual wxObjectRefData *CreateRefData() const
|
||||||
{ return new wxPGCellData(); }
|
{ return new wxPGCellData(); }
|
||||||
@@ -2395,6 +2402,11 @@ protected:
|
|||||||
|
|
||||||
void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
|
void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
|
||||||
|
|
||||||
|
// Called when the property is being removed from the grid and/or
|
||||||
|
// page state (but *not* when it is also deleted).
|
||||||
|
void OnDetached(wxPropertyGridPageState* state,
|
||||||
|
wxPropertyGrid* propgrid);
|
||||||
|
|
||||||
// Call after fixed sub-properties added/removed after creation.
|
// Call after fixed sub-properties added/removed after creation.
|
||||||
// if oldSelInd >= 0 and < new max items, then selection is
|
// if oldSelInd >= 0 and < new max items, then selection is
|
||||||
// moved to it.
|
// moved to it.
|
||||||
|
@@ -1030,13 +1030,17 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
|
|||||||
wxPGProperty* p;
|
wxPGProperty* p;
|
||||||
|
|
||||||
wxPGProperty* origParent =
|
wxPGProperty* origParent =
|
||||||
pgman->GetProperty(wxT("Window Styles"))->GetParent();
|
pgman->GetProperty("Window Styles")->GetParent();
|
||||||
|
|
||||||
p = pgman->RemoveProperty(wxT("Window Styles"));
|
// For testing purposes, let's set some custom cell colours
|
||||||
|
p = pgman->GetProperty("Window Styles");
|
||||||
|
p->SetCell(2, wxPGCell("style"));
|
||||||
|
p = pgman->RemoveProperty("Window Styles");
|
||||||
pgman->Refresh();
|
pgman->Refresh();
|
||||||
pgman->Update();
|
pgman->Update();
|
||||||
|
|
||||||
pgman->AppendIn(origParent, p);
|
pgman->AppendIn(origParent, p);
|
||||||
|
wxASSERT( p->GetCell(2).GetText() == "style");
|
||||||
pgman->Refresh();
|
pgman->Refresh();
|
||||||
pgman->Update();
|
pgman->Update();
|
||||||
}
|
}
|
||||||
|
@@ -499,6 +499,23 @@ void wxPGProperty::InitAfterAdded( wxPropertyGridPageState* pageState,
|
|||||||
wxPGProperty* parent = m_parent;
|
wxPGProperty* parent = m_parent;
|
||||||
bool parentIsRoot = parent->IsKindOf(CLASSINFO(wxPGRootProperty));
|
bool parentIsRoot = parent->IsKindOf(CLASSINFO(wxPGRootProperty));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert invalid cells to default ones in this grid
|
||||||
|
for ( unsigned int i=0; i<m_cells.size(); i++ )
|
||||||
|
{
|
||||||
|
wxPGCell& cell = m_cells[i];
|
||||||
|
if ( cell.IsInvalid() )
|
||||||
|
{
|
||||||
|
const wxPGCell& propDefCell = propgrid->GetPropertyDefaultCell();
|
||||||
|
const wxPGCell& catDefCell = propgrid->GetCategoryDefaultCell();
|
||||||
|
|
||||||
|
if ( !HasFlag(wxPG_PROP_CATEGORY) )
|
||||||
|
cell = propDefCell;
|
||||||
|
else
|
||||||
|
cell = catDefCell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_parentState = pageState;
|
m_parentState = pageState;
|
||||||
|
|
||||||
#if wxPG_COMPATIBILITY_1_4
|
#if wxPG_COMPATIBILITY_1_4
|
||||||
@@ -621,6 +638,27 @@ void wxPGProperty::InitAfterAdded( wxPropertyGridPageState* pageState,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPGProperty::OnDetached(wxPropertyGridPageState* WXUNUSED(state),
|
||||||
|
wxPropertyGrid* propgrid)
|
||||||
|
{
|
||||||
|
if ( propgrid )
|
||||||
|
{
|
||||||
|
const wxPGCell& propDefCell = propgrid->GetPropertyDefaultCell();
|
||||||
|
const wxPGCell& catDefCell = propgrid->GetCategoryDefaultCell();
|
||||||
|
|
||||||
|
// Make default cells invalid
|
||||||
|
for ( unsigned int i=0; i<m_cells.size(); i++ )
|
||||||
|
{
|
||||||
|
wxPGCell& cell = m_cells[i];
|
||||||
|
if ( cell.IsSameAs(propDefCell) ||
|
||||||
|
cell.IsSameAs(catDefCell) )
|
||||||
|
{
|
||||||
|
cell.UnRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxPGProperty::wxPGProperty()
|
wxPGProperty::wxPGProperty()
|
||||||
: wxObject()
|
: wxObject()
|
||||||
{
|
{
|
||||||
@@ -1525,6 +1563,8 @@ void wxPGProperty::EnsureCells( unsigned int column )
|
|||||||
wxPropertyGrid* pg = GetGrid();
|
wxPropertyGrid* pg = GetGrid();
|
||||||
wxPGCell defaultCell;
|
wxPGCell defaultCell;
|
||||||
|
|
||||||
|
if ( pg )
|
||||||
|
{
|
||||||
// Work around possible VC6 bug by using intermediate variables
|
// Work around possible VC6 bug by using intermediate variables
|
||||||
const wxPGCell& propDefCell = pg->GetPropertyDefaultCell();
|
const wxPGCell& propDefCell = pg->GetPropertyDefaultCell();
|
||||||
const wxPGCell& catDefCell = pg->GetCategoryDefaultCell();
|
const wxPGCell& catDefCell = pg->GetCategoryDefaultCell();
|
||||||
@@ -1533,6 +1573,7 @@ void wxPGProperty::EnsureCells( unsigned int column )
|
|||||||
defaultCell = propDefCell;
|
defaultCell = propDefCell;
|
||||||
else
|
else
|
||||||
defaultCell = catDefCell;
|
defaultCell = catDefCell;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Replace with resize() call
|
// TODO: Replace with resize() call
|
||||||
unsigned int cellCountMax = column+1;
|
unsigned int cellCountMax = column+1;
|
||||||
|
@@ -1934,6 +1934,8 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
// We can actually delete it now
|
// We can actually delete it now
|
||||||
if ( doDelete )
|
if ( doDelete )
|
||||||
delete item;
|
delete item;
|
||||||
|
else
|
||||||
|
item->OnDetached(this, pg);
|
||||||
|
|
||||||
m_itemsAdded = 1; // Not a logical assignment (but required nonetheless).
|
m_itemsAdded = 1; // Not a logical assignment (but required nonetheless).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user