mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(FriendList): exclusion of possible undefined behavior
This commit is contained in:
parent
0352ada08c
commit
a1b08d6493
|
@ -40,6 +40,11 @@ bool FriendListManager::getPositionsChanged() const
|
|||
return positionsChanged;
|
||||
}
|
||||
|
||||
bool FriendListManager::getGroupsOnTop() const
|
||||
{
|
||||
return groupsOnTop;
|
||||
}
|
||||
|
||||
void FriendListManager::addFriendListItem(IFriendListItem *item)
|
||||
{
|
||||
if (item->isGroup() && item->getWidget() != nullptr) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
bool needHideCircles() const;
|
||||
// If the contact positions have changed, need to redraw view
|
||||
bool getPositionsChanged() const;
|
||||
bool getGroupsOnTop() const;
|
||||
|
||||
void addFriendListItem(IFriendListItem* item);
|
||||
void removeFriendListItem(IFriendListItem* item);
|
||||
|
@ -69,11 +70,11 @@ private:
|
|||
|
||||
bool byName = true;
|
||||
bool hideCircles = false;
|
||||
bool groupsOnTop;
|
||||
bool positionsChanged;
|
||||
bool needSort;
|
||||
bool groupsOnTop = true;
|
||||
bool positionsChanged = false;
|
||||
bool needSort = false;
|
||||
QVector<IFriendListItemPtr> items;
|
||||
// At startup, while the size of items is less than countContacts, the view will not be processed to improve performance
|
||||
int countContacts;
|
||||
int countContacts = 0;
|
||||
|
||||
};
|
||||
|
|
|
@ -148,6 +148,11 @@ public:
|
|||
return this;
|
||||
}
|
||||
|
||||
bool getGroupsOnTop()
|
||||
{
|
||||
return groupsOnTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief buildUnsorted Creates items to init the FriendListManager.
|
||||
* FriendListManager will own and manage these items
|
||||
|
@ -341,6 +346,7 @@ void TestFriendListManager::testSortByName()
|
|||
QCOMPARE(success, true);
|
||||
QCOMPARE(manager->getPositionsChanged(), false);
|
||||
QCOMPARE(manager->getItems().size(), sortedVec.size());
|
||||
QCOMPARE(manager->getGroupsOnTop(), listBuilder.getGroupsOnTop());
|
||||
|
||||
for (int i = 0; i < sortedVec.size(); ++i) {
|
||||
IFriendListItem* fromManager = manager->getItems().at(i).get();
|
||||
|
|
Loading…
Reference in New Issue
Block a user