Fix signal connection nodiscard warnings (#4818)
This commit is contained in:
@@ -50,7 +50,7 @@ AbstractIrcServer::AbstractIrcServer()
|
||||
this->writeConnection_->connectionLost, [this](bool timeout) {
|
||||
qCDebug(chatterinoIrc)
|
||||
<< "Write connection reconnect requested. Timeout:" << timeout;
|
||||
this->writeConnection_->smartReconnect.invoke();
|
||||
this->writeConnection_->smartReconnect();
|
||||
});
|
||||
|
||||
// Listen to read connection message signals
|
||||
@@ -86,7 +86,7 @@ AbstractIrcServer::AbstractIrcServer()
|
||||
this->addGlobalSystemMessage(
|
||||
"Server connection timed out, reconnecting");
|
||||
}
|
||||
this->readConnection_->smartReconnect.invoke();
|
||||
this->readConnection_->smartReconnect();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,9 @@ void IrcServerData::setPassword(const QString &password)
|
||||
|
||||
Irc::Irc()
|
||||
{
|
||||
this->connections.itemInserted.connect([this](auto &&args) {
|
||||
// We can safely ignore this signal connection since `connections` will always
|
||||
// be destroyed before the Irc object
|
||||
std::ignore = this->connections.itemInserted.connect([this](auto &&args) {
|
||||
// make sure only one id can only exist for one server
|
||||
assert(this->servers_.find(args.item.id) == this->servers_.end());
|
||||
|
||||
@@ -117,7 +119,9 @@ Irc::Irc()
|
||||
}
|
||||
});
|
||||
|
||||
this->connections.itemRemoved.connect([this](auto &&args) {
|
||||
// We can safely ignore this signal connection since `connections` will always
|
||||
// be destroyed before the Irc object
|
||||
std::ignore = this->connections.itemRemoved.connect([this](auto &&args) {
|
||||
// restore
|
||||
if (auto server = this->servers_.find(args.item.id);
|
||||
server != this->servers_.end())
|
||||
@@ -141,7 +145,9 @@ Irc::Irc()
|
||||
}
|
||||
});
|
||||
|
||||
this->connections.delayedItemsChanged.connect([this] {
|
||||
// We can safely ignore this signal connection since `connections` will always
|
||||
// be destroyed before the Irc object
|
||||
std::ignore = this->connections.delayedItemsChanged.connect([this] {
|
||||
this->save();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,18 +38,6 @@ IrcConnection::IrcConnection(QObject *parent)
|
||||
}
|
||||
});
|
||||
|
||||
// Schedule a reconnect that won't violate RECONNECT_MIN_INTERVAL
|
||||
this->smartReconnect.connect([this] {
|
||||
if (this->reconnectTimer_.isActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto delay = this->reconnectBackoff_.next();
|
||||
qCDebug(chatterinoIrc) << "Reconnecting in" << delay.count() << "ms";
|
||||
this->reconnectTimer_.start(delay);
|
||||
});
|
||||
|
||||
this->reconnectTimer_.setSingleShot(true);
|
||||
QObject::connect(&this->reconnectTimer_, &QTimer::timeout, [this] {
|
||||
if (this->isConnected())
|
||||
@@ -123,6 +111,19 @@ IrcConnection::~IrcConnection()
|
||||
this->disconnect();
|
||||
}
|
||||
|
||||
void IrcConnection::smartReconnect()
|
||||
{
|
||||
if (this->reconnectTimer_.isActive())
|
||||
{
|
||||
// Ignore this reconnect request, we already have a reconnect request queued up
|
||||
return;
|
||||
}
|
||||
|
||||
auto delay = this->reconnectBackoff_.next();
|
||||
qCDebug(chatterinoIrc) << "Reconnecting in" << delay.count() << "ms";
|
||||
this->reconnectTimer_.start(delay);
|
||||
}
|
||||
|
||||
void IrcConnection::open()
|
||||
{
|
||||
this->expectConnectionLoss_ = false;
|
||||
|
||||
@@ -20,7 +20,8 @@ public:
|
||||
pajlada::Signals::Signal<bool> connectionLost;
|
||||
|
||||
// Request a reconnect with a minimum interval between attempts.
|
||||
pajlada::Signals::NoArgSignal smartReconnect;
|
||||
// This won't violate RECONNECT_MIN_INTERVAL
|
||||
void smartReconnect();
|
||||
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
|
||||
Reference in New Issue
Block a user