From 03b32bffc8a6f91add465f5366e1fb17b65d4dbb Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Thu, 2 Nov 2023 13:12:52 +0100 Subject: [PATCH 1/2] Bugfix: Fixed a crash when clicking `More messages below` button in a usercard and closing it quickly. (#4933) --- CHANGELOG.md | 1 + src/widgets/helper/ChannelView.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe665295b7..4555e262795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Bugfix: Fixed the input completion popup from disappearing when clicking on it on Windows and macOS. (#4876) - Bugfix: Fixed double-click text selection moving its position with each new message. (#4898) - Bugfix: Fixed an issue where notifications on Windows would contain no or an old avatar. (#4899) +- Bugfix: Fixed a crash when clicking `More messages below` button in a usercard and closing it quickly. (#4933) - Dev: Change clang-format from v14 to v16. (#4929) - Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791) - Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 797ba49fc31..a50bcde1be6 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -351,7 +351,7 @@ void ChannelView::initializeLayout() QObject::connect( this->goToBottom_, &EffectLabel::leftClicked, this, [this] { - QTimer::singleShot(180, [this] { + QTimer::singleShot(180, this, [this] { this->scrollBar_->scrollToBottom( getSettings()->enableSmoothScrollingNewMessages.getValue()); }); From 4e63a1b6ec5d6b2a99360d0037ca123a9cf48416 Mon Sep 17 00:00:00 2001 From: pajlada Date: Thu, 2 Nov 2023 15:48:12 +0100 Subject: [PATCH 2/2] refactor: Message (#4915) * Helix: Remove static from anon namespace * Message: Remove empty anon namespace * Message: Remove else after return * Message: Avoid repeating type in return * Message: Remove ScrollbarHighlight alias * Message: Remove unused includes * AttachedWindow: Remove unused include --- src/messages/Message.cpp | 65 ++++++++++++++++-------------- src/providers/twitch/api/Helix.cpp | 4 +- src/widgets/AttachedWindow.cpp | 1 - 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index cb005a84355..73f8ccde038 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -1,18 +1,11 @@ #include "messages/Message.hpp" -#include "Application.hpp" -#include "MessageElement.hpp" #include "providers/colors/ColorProvider.hpp" -#include "providers/twitch/PubSubActions.hpp" #include "providers/twitch/TwitchBadge.hpp" #include "singletons/Settings.hpp" -#include "singletons/Theme.hpp" #include "util/DebugCount.hpp" -#include "util/IrcHelpers.hpp" #include "widgets/helper/ScrollbarHighlight.hpp" -using SBHighlight = chatterino::ScrollbarHighlight; - namespace chatterino { Message::Message() @@ -26,45 +19,57 @@ Message::~Message() DebugCount::decrease("messages"); } -SBHighlight Message::getScrollBarHighlight() const +ScrollbarHighlight Message::getScrollBarHighlight() const { if (this->flags.has(MessageFlag::Highlighted) || this->flags.has(MessageFlag::HighlightedWhisper)) { - return SBHighlight(this->highlightColor); + return { + this->highlightColor, + }; } - else if (this->flags.has(MessageFlag::Subscription) && - getSettings()->enableSubHighlight) + + if (this->flags.has(MessageFlag::Subscription) && + getSettings()->enableSubHighlight) { - return SBHighlight( - ColorProvider::instance().color(ColorType::Subscription)); + return { + ColorProvider::instance().color(ColorType::Subscription), + }; } - else if (this->flags.has(MessageFlag::RedeemedHighlight) || - this->flags.has(MessageFlag::RedeemedChannelPointReward)) + + if (this->flags.has(MessageFlag::RedeemedHighlight) || + this->flags.has(MessageFlag::RedeemedChannelPointReward)) { - return SBHighlight( + return { ColorProvider::instance().color(ColorType::RedeemedHighlight), - SBHighlight::Default, true); + ScrollbarHighlight::Default, + true, + }; } - else if (this->flags.has(MessageFlag::ElevatedMessage)) + + if (this->flags.has(MessageFlag::ElevatedMessage)) { - return SBHighlight(ColorProvider::instance().color( - ColorType::ElevatedMessageHighlight), - SBHighlight::Default, false, false, true); + return { + ColorProvider::instance().color( + ColorType::ElevatedMessageHighlight), + ScrollbarHighlight::Default, + false, + false, + true, + }; } - else if (this->flags.has(MessageFlag::FirstMessage)) + + if (this->flags.has(MessageFlag::FirstMessage)) { - return SBHighlight( + return { ColorProvider::instance().color(ColorType::FirstMessageHighlight), - SBHighlight::Default, false, true); + ScrollbarHighlight::Default, + false, + true, + }; } - return SBHighlight(); + return {}; } -// Static -namespace { - -} // namespace - } // namespace chatterino diff --git a/src/providers/twitch/api/Helix.cpp b/src/providers/twitch/api/Helix.cpp index 810e02e8755..893cdee10b0 100644 --- a/src/providers/twitch/api/Helix.cpp +++ b/src/providers/twitch/api/Helix.cpp @@ -14,9 +14,9 @@ namespace { using namespace chatterino; -static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100; +constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100; -static constexpr auto NUM_CHATTERS_TO_FETCH = 1000; +constexpr auto NUM_CHATTERS_TO_FETCH = 1000; } // namespace diff --git a/src/widgets/AttachedWindow.cpp b/src/widgets/AttachedWindow.cpp index a3fb20c858c..5ce232a1f2f 100644 --- a/src/widgets/AttachedWindow.cpp +++ b/src/widgets/AttachedWindow.cpp @@ -2,7 +2,6 @@ #include "Application.hpp" #include "common/QLogging.hpp" -#include "ForwardDecl.hpp" #include "singletons/Settings.hpp" #include "util/DebugCount.hpp" #include "widgets/splits/Split.hpp"