fix: send weak ptr to session's checkKeepalive timer (#6204)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
- Bugfix: Fixed some Twitch commands not getting tab-completed correctly. (#6143)
|
||||
- Bugfix: Fixed shared chat badges displaying pixelated when Chatterino is scaled too much. (#6146)
|
||||
- Bugfix: Fixed a crash that could occur when eventsub was enabled and Chatterino was attached to a conhost on Windows that was later gone. (#6161)
|
||||
- Bugfix: Fixed a crash that could occur an eventsub connection's keepalive timer would run after the connection was dead, causing the keepalive timer to use-itself-after-free. (#6204)
|
||||
- Bugfix: Fixed some minor typos. (#6196)
|
||||
- Dev: Mini refactor of Split. (#6148)
|
||||
- Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117)
|
||||
|
||||
@@ -589,15 +589,23 @@ void Session::checkKeepalive()
|
||||
this->keepaliveTimer =
|
||||
std::make_unique<boost::asio::system_timer>(this->ws.get_executor());
|
||||
this->keepaliveTimer->expires_after(this->keepaliveTimeout);
|
||||
this->keepaliveTimer->async_wait([this](boost::system::error_code ec) {
|
||||
if (ec)
|
||||
{
|
||||
this->log->warn(
|
||||
c2fmt::format("Keepalive timer cancelled: {}", ec.message()));
|
||||
return;
|
||||
}
|
||||
this->checkKeepalive();
|
||||
});
|
||||
this->keepaliveTimer->async_wait(
|
||||
[weak{this->weak_from_this()}](boost::system::error_code ec) {
|
||||
auto strong = weak.lock();
|
||||
if (!strong)
|
||||
{
|
||||
// Session was destroyed
|
||||
return;
|
||||
}
|
||||
|
||||
if (ec)
|
||||
{
|
||||
strong->log->warn(c2fmt::format("Keepalive timer cancelled: {}",
|
||||
ec.message()));
|
||||
return;
|
||||
}
|
||||
strong->checkKeepalive();
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace chatterino::eventsub::lib
|
||||
|
||||
@@ -465,6 +465,8 @@ void Controller::createConnection(std::string host, std::string port,
|
||||
std::string path,
|
||||
std::unique_ptr<lib::Listener> listener)
|
||||
{
|
||||
qCDebug(LOG) << "Create EventSub connection";
|
||||
|
||||
try
|
||||
{
|
||||
boost::asio::ssl::context sslContext{
|
||||
|
||||
Reference in New Issue
Block a user