diff --git a/checkin_notes b/checkin_notes index fb635bc2fb..48666cc483 100644 --- a/checkin_notes +++ b/checkin_notes @@ -699,3 +699,13 @@ David 23 Jan 2009 sched/ sched_send.cpp + +Charlie Jan 23 2009 + - MGR: Remove override of GetSelectedItemCount() introduced yesterday; + instead, call DeleteItem() rather than SetItemCount() when number of + rows has been reduced, to allow virtual ListCtrl adjust its list of + selected rows (and thus keep its count in sync with reality.) + + clientgui/ + BOINCBaseView.cpp + BOINCListCtrl.cpp,.h diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 1586b05851..50eae3c654 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -278,12 +278,15 @@ void CBOINCBaseView::OnListRender(wxTimerEvent& event) { m_pListPane->SetItemCount(iDocCount); m_bNeedSort = true; } else { - for (iIndex = 0; iIndex < (iCacheCount - iDocCount); iIndex++) { + // We can't just call SetItemCount() here because we need to + // let the virtual ListCtrl adjust its list of selected rows + // to remove (deselect) any beyond the new last row + for (iIndex = (iCacheCount - 1); iIndex >= iDocCount; --iIndex) { + m_pListPane->DeleteItem(iIndex); iReturnValue = RemoveCacheElement(); wxASSERT(!iReturnValue); } wxASSERT(GetDocCount() == GetCacheCount()); - m_pListPane->SetItemCount(iDocCount); m_pListPane->RefreshItems(0, iDocCount - 1); m_bNeedSort = true; } diff --git a/clientgui/BOINCListCtrl.cpp b/clientgui/BOINCListCtrl.cpp index 64e0a6e70c..88811e7c54 100644 --- a/clientgui/BOINCListCtrl.cpp +++ b/clientgui/BOINCListCtrl.cpp @@ -409,19 +409,6 @@ void MyEvtHandler::OnPaint(wxPaintEvent & event) } } -// Work around a bug in generic list control which doesn't -// adjust count when a selected item is deleted -int CBOINCListCtrl::GetSelectedItemCount() { - - int i = -1, n = 0; - while (1) { - i = GetNextSelected(i); - if (i < 0) break; - n++; - } - return n; -} - #endif diff --git a/clientgui/BOINCListCtrl.h b/clientgui/BOINCListCtrl.h index 768088de9c..f396ba9970 100644 --- a/clientgui/BOINCListCtrl.h +++ b/clientgui/BOINCListCtrl.h @@ -91,7 +91,6 @@ private: void DrawProgressBars(void); wxScrolledWindow* GetMainWin(void) { return (wxScrolledWindow*) m_mainWin; } wxCoord GetHeaderHeight(void) { return m_headerHeight; } - int GetSelectedItemCount(); #endif };