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
@@ -20,7 +20,9 @@ TwitchAccountManager::TwitchAccountManager()
currentUser->loadSeventvUserID();
});
this->accounts.itemRemoved.connect([this](const auto &acc) {
// We can safely ignore this signal connection since accounts will always be removed
// before TwitchAccountManager
std::ignore = this->accounts.itemRemoved.connect([this](const auto &acc) {
this->removeUser(acc.item.get());
});
}
+32 -28
View File
@@ -94,25 +94,15 @@ TwitchChannel::TwitchChannel(const QString &name)
}));
this->refreshPubSub();
this->userStateChanged.connect([this] {
// We can safely ignore this signal connection since it's a private signal, meaning
// it will only ever be invoked by TwitchChannel itself
std::ignore = this->userStateChanged.connect([this] {
this->refreshPubSub();
});
// room id loaded -> refresh live status
this->roomIdChanged.connect([this]() {
this->refreshPubSub();
this->refreshBadges();
this->refreshCheerEmotes();
this->refreshFFZChannelEmotes(false);
this->refreshBTTVChannelEmotes(false);
this->refreshSevenTVChannelEmotes(false);
this->joinBttvChannel();
this->listenSevenTVCosmetics();
getIApp()->getTwitchLiveController()->add(
std::dynamic_pointer_cast<TwitchChannel>(shared_from_this()));
});
this->connected.connect([this]() {
// We can safely ignore this signal connection this has no external dependencies - once the signal
// is destroyed, it will no longer be able to fire
std::ignore = this->connected.connect([this]() {
if (this->roomId().isEmpty())
{
// If we get a reconnected event when the room id is not set, we
@@ -125,18 +115,7 @@ TwitchChannel::TwitchChannel(const QString &name)
this->loadRecentMessagesReconnect();
});
this->messageRemovedFromStart.connect([this](MessagePtr &msg) {
if (msg->replyThread)
{
if (msg->replyThread->liveCount(msg) == 0)
{
this->threads_.erase(msg->replyThread->rootId());
}
}
});
// timers
QObject::connect(&this->chattersListTimer_, &QTimer::timeout, [this] {
this->refreshChatters();
});
@@ -538,6 +517,20 @@ void TwitchChannel::showLoginMessage()
this->addMessage(builder.release());
}
void TwitchChannel::roomIdChanged()
{
this->refreshPubSub();
this->refreshBadges();
this->refreshCheerEmotes();
this->refreshFFZChannelEmotes(false);
this->refreshBTTVChannelEmotes(false);
this->refreshSevenTVChannelEmotes(false);
this->joinBttvChannel();
this->listenSevenTVCosmetics();
getIApp()->getTwitchLiveController()->add(
std::dynamic_pointer_cast<TwitchChannel>(shared_from_this()));
}
QString TwitchChannel::prepareMessage(const QString &message) const
{
auto app = getApp();
@@ -729,7 +722,7 @@ void TwitchChannel::setRoomId(const QString &id)
if (*this->roomID_.accessConst() != id)
{
*this->roomID_.access() = id;
this->roomIdChanged.invoke();
this->roomIdChanged();
this->loadRecentMessages();
}
}
@@ -1063,6 +1056,17 @@ bool TwitchChannel::tryReplaceLastLiveUpdateAddOrRemove(
return true;
}
void TwitchChannel::messageRemovedFromStart(const MessagePtr &msg)
{
if (msg->replyThread)
{
if (msg->replyThread->liveCount(msg) == 0)
{
this->threads_.erase(msg->replyThread->rootId());
}
}
}
const QString &TwitchChannel::subscriptionUrl()
{
return this->subscriptionUrl_;
+8 -4
View File
@@ -191,8 +191,7 @@ public:
const std::unordered_map<QString, std::weak_ptr<MessageThread>> &threads()
const;
// Signals
pajlada::Signals::NoArgSignal roomIdChanged;
// Only TwitchChannel may invoke this signal
pajlada::Signals::NoArgSignal userStateChanged;
/**
@@ -242,8 +241,6 @@ private:
QString actualDisplayName;
} nameOptions;
private:
// Methods
void refreshPubSub();
void refreshChatters();
void refreshBadges();
@@ -252,6 +249,11 @@ private:
void loadRecentMessagesReconnect();
void cleanUpReplyThreads();
void showLoginMessage();
/// roomIdChanged is called whenever this channel's ID has been changed
/// This should only happen once per channel, whenever the ID goes from unset to set
void roomIdChanged();
/** Joins (subscribes to) a Twitch channel for updates on BTTV. */
void joinBttvChannel() const;
/**
@@ -335,6 +337,8 @@ private:
std::unordered_map<QString, std::weak_ptr<MessageThread>> threads_;
protected:
void messageRemovedFromStart(const MessagePtr &msg) override;
Atomic<std::shared_ptr<const EmoteMap>> bttvEmotes_;
Atomic<std::shared_ptr<const EmoteMap>> ffzEmotes_;
Atomic<std::shared_ptr<const EmoteMap>> seventvEmotes_;
+8 -5
View File
@@ -133,21 +133,24 @@ void TwitchIrcServer::initializeConnection(IrcConnection *connection,
std::shared_ptr<Channel> TwitchIrcServer::createChannel(
const QString &channelName)
{
auto channel =
std::shared_ptr<TwitchChannel>(new TwitchChannel(channelName));
auto channel = std::make_shared<TwitchChannel>(channelName);
channel->initialize();
channel->sendMessageSignal.connect(
// We can safely ignore these signal connections since the TwitchIrcServer is only
// ever destroyed when the full Application state is about to be destroyed, at which point
// no Channel's should live
// NOTE: CHANNEL_LIFETIME
std::ignore = channel->sendMessageSignal.connect(
[this, channel = channel.get()](auto &chan, auto &msg, bool &sent) {
this->onMessageSendRequested(channel, msg, sent);
});
channel->sendReplySignal.connect(
std::ignore = channel->sendReplySignal.connect(
[this, channel = channel.get()](auto &chan, auto &msg, auto &replyId,
bool &sent) {
this->onReplySendRequested(channel, msg, replyId, sent);
});
return std::shared_ptr<Channel>(channel);
return channel;
}
void TwitchIrcServer::privateMessageReceived(