From 829c48d79aff6efd6f6a1d73c2a4609e8c331c30 Mon Sep 17 00:00:00 2001 From: nerix Date: Thu, 9 Feb 2023 00:43:52 +0100 Subject: [PATCH] Attempt to catch `std::bad_function_call` when adding a channel point reward (#4360) * fix: attempt to catch std::bad_function_call * chore: add changelog entry * fix: spelling mistake Co-authored-by: Leon Richardt --------- Co-authored-by: Leon Richardt --- CHANGELOG.md | 1 + src/providers/twitch/TwitchChannel.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f34224a5..e9aa1ccae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Bugfix: Fixed the split "Search" menu action not opening the correct search window. (#4305) - Bugfix: Fixed an issue on Windows when opening links in incognito mode that contained forward slashes in hash (#4307) - Bugfix: Fixed an issue where beta versions wouldn't update to stable versions correctly. (#4329) +- Bugfix: Avoided crash that could occur when receiving channel point reward information. (#4360) - Dev: Changed sound backend from Qt to miniaudio. (#4334) - Dev: Remove protocol from QApplication's Organization Domain (so changed from `https://www.chatterino.com` to `chatterino.com`). (#4256) - Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index ec8405c1a..a06e61b0b 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -304,7 +304,21 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward) << "[TwitchChannel" << this->getName() << "] Channel point reward added:" << reward.id << "," << reward.title << "," << reward.isUserInputRequired; - this->channelPointRewardAdded.invoke(reward); + + // TODO: There's an underlying bug here. This bug should be fixed. + // This only attempts to prevent a crash when invoking the signal. + try + { + this->channelPointRewardAdded.invoke(reward); + } + catch (const std::bad_function_call &) + { + qCWarning(chatterinoTwitch).nospace() + << "[TwitchChannel " << this->getName() + << "] Caught std::bad_function_call when adding channel point " + "reward ChannelPointReward{ id: " + << reward.id << ", title: " << reward.title << " }."; + } } }