fix: ensure liveupdate pubsubs exit (#5557)
Previously, the derived class (i.e. BttvLiveUpdates or SeventvEventAPI)
would have their destructor ran before BasicPubSubManager called
stop, meaning there was a time wherein messages could still flow
through, attempting to call `onMessage` on a pure virtual, causing a
crash.
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
- Bugfix: Fixed windows on Windows not saving correctly when snapping them to the edges. (#5478)
|
- Bugfix: Fixed windows on Windows not saving correctly when snapping them to the edges. (#5478)
|
||||||
- Bugfix: Fixed user info card popups adding duplicate line to log files. (#5499)
|
- Bugfix: Fixed user info card popups adding duplicate line to log files. (#5499)
|
||||||
- Bugfix: Fixed tooltips and input completion popups not working after moving a split. (#5541)
|
- Bugfix: Fixed tooltips and input completion popups not working after moving a split. (#5541)
|
||||||
|
- Bugfix: Fixed rare issue on shutdown where the client would hang. (#5557)
|
||||||
- Bugfix: Fixed `/clearmessages` not working with more than one window. (#5489)
|
- Bugfix: Fixed `/clearmessages` not working with more than one window. (#5489)
|
||||||
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504)
|
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504)
|
||||||
- Bugfix: Links with invalid characters in the domain are no longer detected. (#5509)
|
- Bugfix: Links with invalid characters in the domain are no longer detected. (#5509)
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ BttvLiveUpdates::BttvLiveUpdates(QString host)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BttvLiveUpdates::~BttvLiveUpdates()
|
||||||
|
{
|
||||||
|
this->stop();
|
||||||
|
}
|
||||||
|
|
||||||
void BttvLiveUpdates::joinChannel(const QString &channelID,
|
void BttvLiveUpdates::joinChannel(const QString &channelID,
|
||||||
const QString &userName)
|
const QString &userName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class BttvLiveUpdates : public BasicPubSubManager<BttvLiveUpdateSubscription>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BttvLiveUpdates(QString host);
|
BttvLiveUpdates(QString host);
|
||||||
|
~BttvLiveUpdates() override;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Signal<BttvLiveUpdateEmoteUpdateAddMessage> emoteAdded;
|
Signal<BttvLiveUpdateEmoteUpdateAddMessage> emoteAdded;
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ public:
|
|||||||
|
|
||||||
virtual ~BasicPubSubManager()
|
virtual ~BasicPubSubManager()
|
||||||
{
|
{
|
||||||
this->stop();
|
// The derived class must call stop in its destructor
|
||||||
|
assert(this->stopping_);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicPubSubManager(const BasicPubSubManager &) = delete;
|
BasicPubSubManager(const BasicPubSubManager &) = delete;
|
||||||
@@ -127,6 +128,11 @@ public:
|
|||||||
|
|
||||||
void stop()
|
void stop()
|
||||||
{
|
{
|
||||||
|
if (this->stopping_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->stopping_ = true;
|
this->stopping_ = true;
|
||||||
|
|
||||||
for (const auto &client : this->clients_)
|
for (const auto &client : this->clients_)
|
||||||
@@ -138,10 +144,20 @@ public:
|
|||||||
|
|
||||||
if (this->mainThread_->joinable())
|
if (this->mainThread_->joinable())
|
||||||
{
|
{
|
||||||
this->mainThread_->join();
|
// NOTE: We spawn a new thread to join the websocket thread.
|
||||||
|
// There is a case where a new client was initiated but not added to the clients list.
|
||||||
|
// We just don't join the thread & let the operating system nuke the thread if joining fails
|
||||||
|
// within 1s.
|
||||||
|
auto joiner = std::async(std::launch::async, &std::thread::join,
|
||||||
|
this->mainThread_.get());
|
||||||
|
if (joiner.wait_for(std::chrono::seconds(1)) ==
|
||||||
|
std::future_status::timeout)
|
||||||
|
{
|
||||||
|
qCWarning(chatterinoLiveupdates)
|
||||||
|
<< "Thread didn't join within 1 second, rip it out";
|
||||||
|
this->websocketClient_.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(this->clients_.empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ SeventvEventAPI::SeventvEventAPI(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SeventvEventAPI::~SeventvEventAPI()
|
||||||
|
{
|
||||||
|
this->stop();
|
||||||
|
}
|
||||||
|
|
||||||
void SeventvEventAPI::subscribeUser(const QString &userID,
|
void SeventvEventAPI::subscribeUser(const QString &userID,
|
||||||
const QString &emoteSetID)
|
const QString &emoteSetID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public:
|
|||||||
std::chrono::milliseconds defaultHeartbeatInterval =
|
std::chrono::milliseconds defaultHeartbeatInterval =
|
||||||
std::chrono::milliseconds(25000));
|
std::chrono::milliseconds(25000));
|
||||||
|
|
||||||
|
~SeventvEventAPI() override;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Signal<seventv::eventapi::EmoteAddDispatch> emoteAdded;
|
Signal<seventv::eventapi::EmoteAddDispatch> emoteAdded;
|
||||||
Signal<seventv::eventapi::EmoteUpdateDispatch> emoteUpdated;
|
Signal<seventv::eventapi::EmoteUpdateDispatch> emoteUpdated;
|
||||||
|
|||||||
@@ -581,8 +581,6 @@ void PubSub::stop()
|
|||||||
this->websocketClient.stop();
|
this->websocketClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(this->clients.empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PubSub::listenToWhispers()
|
bool PubSub::listenToWhispers()
|
||||||
|
|||||||
Reference in New Issue
Block a user