Fixed incorrect use of the sort() function. It expects a "less than"
compare function with bool return value, not a -1/0/1 returning compare function. Fixes bug #1158 (registrar crash on shutdown). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20733 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
621b401de4
commit
d619e89985
@ -186,15 +186,16 @@ AppInfoList::It()
|
||||
// Sort
|
||||
/*! \brief Sorts the infos in ascending order according to the given compare
|
||||
function.
|
||||
\param cmpFunc The compare function to be used.
|
||||
\param lessFunc The compare function (less than) to be used.
|
||||
*/
|
||||
void
|
||||
AppInfoList::Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *))
|
||||
AppInfoList::Sort(
|
||||
bool (*lessFunc)(const RosterAppInfo *, const RosterAppInfo *))
|
||||
{
|
||||
int32 count = CountInfos();
|
||||
if (count > 1) {
|
||||
RosterAppInfo **infos = (RosterAppInfo **)fInfos.Items();
|
||||
std::sort(infos, infos + count, cmpFunc);
|
||||
std::sort(infos, infos + count, lessFunc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
Iterator It();
|
||||
|
||||
void Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *));
|
||||
void Sort(bool (*lessFunc)(const RosterAppInfo *, const RosterAppInfo *));
|
||||
|
||||
private:
|
||||
RosterAppInfo *RemoveInfo(int32 index);
|
||||
|
@ -95,14 +95,11 @@ enum {
|
||||
|
||||
// inverse_compare_by_registration_time
|
||||
static
|
||||
int
|
||||
bool
|
||||
inverse_compare_by_registration_time(const RosterAppInfo *info1,
|
||||
const RosterAppInfo *info2)
|
||||
{
|
||||
bigtime_t cmp = info1->registration_time - info2->registration_time;
|
||||
if (cmp < 0)
|
||||
return 1;
|
||||
return (cmp > 0 ? -1 : 0);
|
||||
return (info2->registration_time < info1->registration_time);
|
||||
}
|
||||
|
||||
// throw_error
|
||||
|
Loading…
Reference in New Issue
Block a user