Fix wxDataViewCtrl::GetItemRect() for collapsed items
Calling GetItemRect() for an item which was not currently visible because its parent was collapsed resulted in silently returning the value for a wrong value before the recent fix to GetRowByItem() and in a crash after it because GetTreeNodeByRow() returned null when passed invalid row index. Fix this by explicitly checking whether the item is shown and just returning an empty rectangle instead. Also document this behaviour and add a unit test for it.
This commit is contained in:
@@ -198,4 +198,24 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
CHECK( !m_dvc->IsExpanded(m_child2) );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::GetItemRect",
|
||||
"[wxDataViewCtrl][item]")
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
WARN("Disabled under GTK because GetItemRect() is not implemented");
|
||||
#else
|
||||
const wxRect rect1 = m_dvc->GetItemRect(m_child1);
|
||||
const wxRect rect2 = m_dvc->GetItemRect(m_child2);
|
||||
|
||||
CHECK( rect1.x == rect2.x );
|
||||
CHECK( rect1.width == rect2.width );
|
||||
CHECK( rect1.height == rect2.height );
|
||||
CHECK( rect1.y < rect2.y );
|
||||
|
||||
const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild);
|
||||
CHECK( rectNotShown == wxRect() );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //wxUSE_DATAVIEWCTRL
|
||||
|
Reference in New Issue
Block a user