Possible exception after RemoveRecordEx calling |
Post Reply |
Author | |
DiZSl
Groupie Joined: 08 August 2020 Status: Offline Points: 10 |
Post Options
Thanks(0)
Posted: 29 November 2024 at 1:40am |
After calling RemoveRecordEx, it is essential to call UpdateWindows for the ReportControl. If this is not done and a user quickly clicks on the deleted record before the window is redrawn (updated), the function HitTest in CXTPReportControl::OnButton will return the deleted CXTPReportRow from the m_pScreenRows array, which is only updated during redrawing. However, the redraw has not yet occurred only invalidating, resulting in m_pScreenRows being out of sync with the main tree.
Additionally, when calling CXTPReportControl::OnButton, this removed CXTPReportRow will be passed to _SetSelectedRow, which will cause an index for a non-existent record to appear in the m_pSelectedRows array. As a result, m_pSelectedRows.GetCount will return 1, while m_pSelectedRows.GetAt(0) will return nullptr. My solution (remove row from m_pScreenRows): void CXTPReportRows::RemoveAt(int nIndex) { auto row = m_arrRows.GetAt(nIndex); if (row != nullptr) { auto rows = GetScreenRows(); if (rows != nullptr) { auto size = rows->GetCount(); for (int i = 0; i < size; i++) { if (rows->GetAt(i) == row) { row->InternalRelease(); rows->RemoveAt(i); break; } } } row->InternalRelease(); } m_arrRows.RemoveAt(nIndex); } |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |