mirror of https://github.com/BOINC/boinc.git
MGR: Use std::stable_sort to stop rows with equal values in the sort column changing places randomly
svn path=/trunk/boinc/; revision=15561
This commit is contained in:
parent
75bd883fcb
commit
af866dd801
|
@ -5502,7 +5502,16 @@ David 6 July 2008
|
|||
Charlie 8 July 2008
|
||||
- MGR: Add "Show only this project" button to messages tab; filters
|
||||
message display to show only messages for the selected project.
|
||||
- MGR: Fix problem of rows with equal values in the sort column
|
||||
changing places randomly with each re-sort. wxArrayInt::Sort()
|
||||
uses std::sort(), which is not stable in such cases. The
|
||||
solution is to use std::stable_sort() instea
|
||||
|
||||
|
||||
clientgui/
|
||||
Events.h
|
||||
BOINCBaseView.cpp,.h
|
||||
ViewMessages.cpp,.h
|
||||
ViewProjects.cpp
|
||||
ViewTransfers.cpp
|
||||
ViewWork.cpp
|
||||
|
|
|
@ -530,7 +530,7 @@ void CBOINCBaseView::sortData() {
|
|||
m_pListPane->SetItemState(i, 0, wxLIST_STATE_SELECTED);
|
||||
}
|
||||
|
||||
m_iSortedIndexes.Sort(m_funcSortCompare);
|
||||
std::stable_sort(m_iSortedIndexes.begin(), m_iSortedIndexes.end(), m_funcSortCompare);
|
||||
|
||||
// Reselect previously selected cache elements in the sorted list
|
||||
m = (int)selections.GetCount();
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
std::vector<CTaskItem*> m_Tasks;
|
||||
};
|
||||
|
||||
typedef int (*ListSortCompareFunc)(int*, int*);
|
||||
typedef bool (*ListSortCompareFunc)(int, int);
|
||||
|
||||
|
||||
class CBOINCBaseView : public wxPanel {
|
||||
|
|
|
@ -92,9 +92,9 @@ END_EVENT_TABLE ()
|
|||
|
||||
static CViewProjects* myCViewProjects;
|
||||
|
||||
static int CompareViewProjectsItems(int *iRowIndex1, int *iRowIndex2) {
|
||||
CProject* project1 = myCViewProjects->m_ProjectCache.at(*iRowIndex1);
|
||||
CProject* project2 = myCViewProjects->m_ProjectCache.at(*iRowIndex2);
|
||||
static bool CompareViewProjectsItems(int iRowIndex1, int iRowIndex2) {
|
||||
CProject* project1 = myCViewProjects->m_ProjectCache.at(iRowIndex1);
|
||||
CProject* project2 = myCViewProjects->m_ProjectCache.at(iRowIndex2);
|
||||
int result = 0;
|
||||
|
||||
switch (myCViewProjects->m_iSortColumn) {
|
||||
|
@ -133,7 +133,8 @@ static int CompareViewProjectsItems(int *iRowIndex1, int *iRowIndex2) {
|
|||
break;
|
||||
}
|
||||
|
||||
return (myCViewProjects->m_bReverseSort ? result * (-1) : result);
|
||||
// Always return FALSE for equality (result == 0)
|
||||
return (myCViewProjects->m_bReverseSort ? (result > 0) : (result <= 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ END_EVENT_TABLE ()
|
|||
|
||||
static CViewTransfers* MyCViewTransfers;
|
||||
|
||||
static int CompareViewTransferItems(int *iRowIndex1, int *iRowIndex2) {
|
||||
CTransfer* transfer1 = MyCViewTransfers->m_TransferCache.at(*iRowIndex1);
|
||||
CTransfer* transfer2 = MyCViewTransfers->m_TransferCache.at(*iRowIndex2);
|
||||
static bool CompareViewTransferItems(int iRowIndex1, int iRowIndex2) {
|
||||
CTransfer* transfer1 = MyCViewTransfers->m_TransferCache.at(iRowIndex1);
|
||||
CTransfer* transfer2 = MyCViewTransfers->m_TransferCache.at(iRowIndex2);
|
||||
int result = 0;
|
||||
|
||||
switch (MyCViewTransfers->m_iSortColumn) {
|
||||
|
@ -124,7 +124,8 @@ static int CompareViewTransferItems(int *iRowIndex1, int *iRowIndex2) {
|
|||
break;
|
||||
}
|
||||
|
||||
return (MyCViewTransfers->m_bReverseSort ? result * (-1) : result);
|
||||
// Always return FALSE for equality (result == 0)
|
||||
return (MyCViewTransfers->m_bReverseSort ? (result > 0) : (result <= 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -91,10 +91,10 @@ END_EVENT_TABLE ()
|
|||
|
||||
static CViewWork* myCViewWork;
|
||||
|
||||
static int CompareViewWorkItems(int *iRowIndex1, int *iRowIndex2) {
|
||||
CWork* work1 = myCViewWork->m_WorkCache.at(*iRowIndex1);
|
||||
CWork* work2 = myCViewWork->m_WorkCache.at(*iRowIndex2);
|
||||
int result = 0;
|
||||
static bool CompareViewWorkItems(int iRowIndex1, int iRowIndex2) {
|
||||
CWork* work1 = myCViewWork->m_WorkCache.at(iRowIndex1);
|
||||
CWork* work2 = myCViewWork->m_WorkCache.at(iRowIndex2);
|
||||
int result = false;
|
||||
|
||||
switch (myCViewWork->m_iSortColumn) {
|
||||
case COLUMN_PROJECT:
|
||||
|
@ -139,7 +139,8 @@ static int CompareViewWorkItems(int *iRowIndex1, int *iRowIndex2) {
|
|||
break;
|
||||
}
|
||||
|
||||
return (myCViewWork->m_bReverseSort ? result * (-1) : result);
|
||||
// Always return FALSE for equality (result == 0)
|
||||
return (myCViewWork->m_bReverseSort ? (result > 0) : (result < 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue