|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Rado Manzela
|
Jun 2, 2009 - 3:37 PM
|
My progam worked in previous versions (€currently 2.84), but after I’ve switched to 2.85 it crashes when I call CExtTreeGridDataProvider::TreeNodeSortChildren() while implementing my recursive sort. Line 1218 in exttreegridwnd.cpp is addressing array behind upper bound by 1. Line is: pNode = m_arrGridVis[ nExpandedOffsetSrc + nIndex ]; // nExpandedOffsetSrc=17, nIndex=1; array size = 18 Do you have idea what could be wrong? Thank you.
|
|
Technical Support
|
Jun 4, 2009 - 1:13 PM
|
Your sorting method is based on the standard sorting. It does not clone or re-create tree nodes and all the HTREEITEM handles are the same after resorting. This means your sorting does not produce invalid HTREEITEM handles and should work without any assertion failures. We re-checked the sorting in the FilteredGrids sample application and in the http://www.prof-uis.com/download/forums/test_tree_grid_idea.zip test project and it works. So, we suppose this assertion depends on some conditions specific for your project and we had to ask you to help us reproduce it with our sample/test projects.
|
|
Rado Manzela
|
Jun 9, 2009 - 12:06 PM
|
Just create 2 items in root, like "b" and "a" (so that it will have to be swapped). Each item must have child, but NOT expanded (tree should look like [+] A
[+] B Then click at column heading to sort it and it will assert. Let me know if you won’t be able to reproduce it, I’ll send some project for you. Thank you
|
|
Technical Support
|
Jun 11, 2009 - 2:23 AM
|
Thank you for reporting the bug. You can fix it by updating the following two methods:
bool CExtTreeGridDataProvider::_Tree_NodeExpand(
CExtTreeGridCellNode * pNode,
INT nActionTVE // = TVE_TOGGLE // TVE_COLLAPSE, TVE_EXPAND, TVE_TOGGLE only
)
{
ASSERT_VALID( this );
ASSERT_VALID( pNode );
ASSERT(
nActionTVE == TVE_COLLAPSE
|| nActionTVE == TVE_EXPAND
|| nActionTVE == TVE_TOGGLE
);
bool bExpanded = pNode->TreeNodeIsExpanded();
if( nActionTVE == TVE_TOGGLE )
{
if( bExpanded )
nActionTVE = TVE_COLLAPSE;
else
nActionTVE = TVE_EXPAND;
}
if( nActionTVE == TVE_EXPAND )
{
if( bExpanded )
return false;
pNode->TreeNodeMarkExpanded( true );
ULONG nWeightVisible = pNode->_ContentWeight_CalcVisible();
if( pNode->TreeNodeIsDisplayed() )
{
ULONG nOffset = pNode->TreeNodeCalcOffset( true, false );
if( nWeightVisible != 0 )
{
m_arrGridVis.InsertAt( ++ nOffset, NULL, nWeightVisible );
pNode->_Content_FillVisibleArray( m_arrGridVis, nOffset );
}
}
pNode->_ContentWeight_Increment( nWeightVisible, true );
}
else
{
if( ! bExpanded )
return false;
ULONG nWeightVisible = pNode->_ContentWeight_CalcVisible();
pNode->TreeNodeMarkExpanded( false );
if( pNode->TreeNodeIsDisplayed() )
{
ULONG nOffset = pNode->TreeNodeCalcOffset( true, false );
if( nWeightVisible != 0 )
m_arrGridVis.RemoveAt( nOffset + 1, nWeightVisible );
}
pNode->_ContentWeight_Decrement( nWeightVisible, true );
}
return true;
}
ULONG CExtTreeGridCellNode::_ContentWeight_CalcVisible() const
{
ASSERT_VALID( this );
if( TreeNodeHiddenGet() )
return 0L;
if( ! TreeNodeIsExpanded() )
return 0L;
ULONG nCount = TreeNodeGetChildCount();
ULONG nCalcVal = 0;
for( ULONG nIdx = 0; nIdx < nCount; nIdx++ )
{
const CExtTreeGridCellNode * pNode = TreeNodeGetChildAt( nIdx );
ASSERT_VALID( pNode );
if( pNode->TreeNodeHiddenGet() )
continue;
nCalcVal ++;
if( pNode->TreeNodeIsExpanded() )
nCalcVal += pNode->_ContentWeight_CalcVisible();
}
return nCalcVal;
}
|
|
Rado Manzela
|
Jun 12, 2009 - 11:46 AM
|
|
|
Technical Support
|
Jun 3, 2009 - 5:32 AM
|
This looks like memory damage or invalid HTREEITEM usage. Please help us reproduce this error. We need to know how did you implement your recursive sorting?
|
|
Rado Manzela
|
Jun 3, 2009 - 12:06 PM
|
Here is my implementation (I call it at root item): void CChildView::SortRecursive(HTREEITEM item, const CExtGridDataSortOrder &_gdso,CExtTreeGridDataProvider & _DP)
{
CExtTreeGridCellNode * pNode = CExtTreeGridCellNode::FromHTREEITEM( item );
ASSERT_VALID( pNode );
_DP.TreeNodeSortChildren( pNode, _gdso, this ) ;
HTREEITEM sItem;
for (sItem = ItemGetFirstChild(item); sItem; sItem = ItemGetNext(sItem,true,false,true))
{
if (ItemGetChildCount(sItem) < 2)
continue;
SortRecursive(sItem,_gdso,_DP);
}
}
|
|