From 83b6fad8e6a6ed33972cefd6e9f6a09a773e1cb5 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sat, 22 Aug 2020 11:45:18 +0200 Subject: [PATCH] fixed some concurrency issues --- src/Application.cpp | 12 ++++++++---- src/common/SignalVector.hpp | 1 + src/providers/twitch/TwitchChannel.cpp | 2 ++ src/singletons/Settings.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 814ba92f5..2c83ec6d9 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -289,10 +289,14 @@ void Application::initPubsub() QString channelId; if (rj::getSafe(data, "channel_id", channelId)) { - const auto &chan = - this->twitch.server->getChannelOrEmptyByID(channelId); - auto channel = dynamic_cast(chan.get()); - channel->addChannelPointReward(ChannelPointReward(data)); + auto chan = this->twitch.server->getChannelOrEmptyByID(channelId); + + auto reward = ChannelPointReward(data); + + postToThread([chan, reward] { + auto channel = dynamic_cast(chan.get()); + channel->addChannelPointReward(reward); + }); } else { diff --git a/src/common/SignalVector.hpp b/src/common/SignalVector.hpp index 33bd8254c..93f1f322e 100644 --- a/src/common/SignalVector.hpp +++ b/src/common/SignalVector.hpp @@ -98,6 +98,7 @@ public: /// signals. int append(const T &item, void *caller = nullptr) { + assertInGuiThread(); return this->insert(item, -1, caller); } diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index c559ff29d..d3ec2f702 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -237,6 +237,8 @@ void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh) void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward) { + assertInGuiThread(); + if (!reward.hasParsedSuccessfully) { return; diff --git a/src/singletons/Settings.cpp b/src/singletons/Settings.cpp index 60e38e554..2316eaef8 100644 --- a/src/singletons/Settings.cpp +++ b/src/singletons/Settings.cpp @@ -34,7 +34,9 @@ ConcurrentSettings::ConcurrentSettings() bool ConcurrentSettings::isHighlightedUser(const QString &username) { - for (const auto &highlightedUser : this->highlightedUsers) + auto items = this->highlightedUsers.readOnly(); + + for (const auto &highlightedUser : *items) { if (highlightedUser.isMatch(username)) return true; @@ -58,7 +60,9 @@ bool ConcurrentSettings::isBlacklistedUser(const QString &username) bool ConcurrentSettings::isMutedChannel(const QString &channelName) { - for (const auto &channel : this->mutedChannels) + auto items = this->mutedChannels.readOnly(); + + for (const auto &channel : *items) { if (channelName.toLower() == channel.toLower()) {