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:
@@ -186,15 +186,16 @@ AppInfoList::It()
|
|||||||
// Sort
|
// Sort
|
||||||
/*! \brief Sorts the infos in ascending order according to the given compare
|
/*! \brief Sorts the infos in ascending order according to the given compare
|
||||||
function.
|
function.
|
||||||
\param cmpFunc The compare function to be used.
|
\param lessFunc The compare function (less than) to be used.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
AppInfoList::Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *))
|
AppInfoList::Sort(
|
||||||
|
bool (*lessFunc)(const RosterAppInfo *, const RosterAppInfo *))
|
||||||
{
|
{
|
||||||
int32 count = CountInfos();
|
int32 count = CountInfos();
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
RosterAppInfo **infos = (RosterAppInfo **)fInfos.Items();
|
RosterAppInfo **infos = (RosterAppInfo **)fInfos.Items();
|
||||||
std::sort(infos, infos + count, cmpFunc);
|
std::sort(infos, infos + count, lessFunc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
Iterator It();
|
Iterator It();
|
||||||
|
|
||||||
void Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *));
|
void Sort(bool (*lessFunc)(const RosterAppInfo *, const RosterAppInfo *));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RosterAppInfo *RemoveInfo(int32 index);
|
RosterAppInfo *RemoveInfo(int32 index);
|
||||||
|
|||||||
@@ -95,14 +95,11 @@ enum {
|
|||||||
|
|
||||||
// inverse_compare_by_registration_time
|
// inverse_compare_by_registration_time
|
||||||
static
|
static
|
||||||
int
|
bool
|
||||||
inverse_compare_by_registration_time(const RosterAppInfo *info1,
|
inverse_compare_by_registration_time(const RosterAppInfo *info1,
|
||||||
const RosterAppInfo *info2)
|
const RosterAppInfo *info2)
|
||||||
{
|
{
|
||||||
bigtime_t cmp = info1->registration_time - info2->registration_time;
|
return (info2->registration_time < info1->registration_time);
|
||||||
if (cmp < 0)
|
|
||||||
return 1;
|
|
||||||
return (cmp > 0 ? -1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// throw_error
|
// throw_error
|
||||||
|
|||||||
Reference in New Issue
Block a user