Only invalidate row height cache when a row is really expanded

It's wasteful to do it if it's already expanded or won't be expanded
because the EXPANDING event is vetoed.
This commit is contained in:
Vadim Zeitlin
2020-12-05 14:16:17 +01:00
parent 1e28312035
commit faffc5fe0a

View File

@@ -3919,13 +3919,6 @@ void wxDataViewMainWindow::Expand( unsigned int row )
if (!node->HasChildren()) if (!node->HasChildren())
return; return;
if ( m_rowHeightCache )
{
// Expand makes new rows visible thus we invalidates all following
// rows in the height cache
m_rowHeightCache->Remove(row);
}
if (!node->IsOpen()) if (!node->IsOpen())
{ {
if ( !SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDING, node->GetItem()) ) if ( !SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDING, node->GetItem()) )
@@ -3934,6 +3927,13 @@ void wxDataViewMainWindow::Expand( unsigned int row )
return; return;
} }
if ( m_rowHeightCache )
{
// Expand makes new rows visible thus we invalidates all following
// rows in the height cache
m_rowHeightCache->Remove(row);
}
node->ToggleOpen(this); node->ToggleOpen(this);
// build the children of current node // build the children of current node