MGR: use instance variables instead of the static (class) variables in my recent commits. This is better practice and safer, though the code did work properly with the static variables because OnCacheHint() is called whenever you select a different tab.

This commit is contained in:
Charlie Fenton 2014-05-21 04:06:47 -07:00
parent 69327a4054
commit a275fc7a0b
2 changed files with 12 additions and 7 deletions

View File

@ -47,6 +47,9 @@ CBOINCBaseView::CBOINCBaseView(wxNotebook* pNotebook) :
m_bIgnoreUIEvents = false;
m_bNeedSort = false;
m_iPreviousSelectionCount = 0;
m_lPreviousFirstSelection = -1;
//
// Setup View
//
@ -70,6 +73,9 @@ CBOINCBaseView::CBOINCBaseView(wxNotebook* pNotebook, wxWindowID iTaskWindowID,
m_bForceUpdateSelection = true;
m_bIgnoreUIEvents = false;
m_iPreviousSelectionCount = 0;
m_lPreviousFirstSelection = -1;
//
// Setup View
//
@ -368,14 +374,11 @@ void CBOINCBaseView::OnListDeselected(wxListEvent& event) {
//
// We currently handle all selections and deselections here.
void CBOINCBaseView::OnCacheHint(wxListEvent& event) {
static int oldSelectionCount = 0;
static long previousSelection = -1;
int newSelectionCount = m_pListPane->GetSelectedItemCount();
long currentSelection = m_pListPane->GetFirstSelected();
if ((newSelectionCount != oldSelectionCount) ||
(currentSelection != previousSelection)
if ((newSelectionCount != m_iPreviousSelectionCount) ||
(currentSelection != m_lPreviousFirstSelection)
) {
if (!m_bIgnoreUIEvents) {
m_bForceUpdateSelection = true;
@ -383,8 +386,8 @@ void CBOINCBaseView::OnCacheHint(wxListEvent& event) {
}
}
oldSelectionCount = newSelectionCount;
previousSelection = currentSelection;
m_iPreviousSelectionCount = newSelectionCount;
m_lPreviousFirstSelection = currentSelection;
event.Skip();
}

View File

@ -190,6 +190,8 @@ protected:
bool m_bIgnoreUIEvents;
bool m_bNeedSort;
int m_iPreviousSelectionCount;
long m_lPreviousFirstSelection;
int m_iProgressColumn;
wxImageList * m_SortArrows;