Fix signal connection nodiscard warnings (#4818)

This commit is contained in:
pajlada
2023-09-16 13:52:51 +02:00
committed by GitHub
parent 2d5f078306
commit 8fe3af3522
40 changed files with 709 additions and 554 deletions
+19 -14
View File
@@ -1,4 +1,4 @@
#include "AccountController.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/accounts/Account.hpp"
#include "controllers/accounts/AccountModel.hpp"
@@ -10,22 +10,27 @@ namespace chatterino {
AccountController::AccountController()
: accounts_(SharedPtrElementLess<Account>{})
{
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
this->accounts_.insert(std::dynamic_pointer_cast<Account>(args.item));
});
// These signal connections can safely be ignored since the twitch object
// will always be destroyed before the AccountController
std::ignore =
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
this->accounts_.insert(
std::dynamic_pointer_cast<Account>(args.item));
});
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
if (args.caller != this)
{
auto &accs = this->twitch.accounts.raw();
auto it = std::find(accs.begin(), accs.end(), args.item);
assert(it != accs.end());
std::ignore =
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
if (args.caller != this)
{
auto &accs = this->twitch.accounts.raw();
auto it = std::find(accs.begin(), accs.end(), args.item);
assert(it != accs.end());
this->accounts_.removeAt(it - accs.begin(), this);
}
});
this->accounts_.removeAt(it - accs.begin(), this);
}
});
this->accounts_.itemRemoved.connect([this](const auto &args) {
std::ignore = this->accounts_.itemRemoved.connect([this](const auto &args) {
switch (args.item->getProviderId())
{
case ProviderId::Twitch: {