diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c44fa4..ea907d89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Bugfix: Fixed the input font not immediately updating when zooming in/out. (#5960) - Bugfix: Fixed missing special shortcut for Windows live notifications. (#5975) - Bugfix: Fixed color input thinking blue is also red. (#5982) +- Bugfix: Fixed a crash that would occurr if the user tried to open the search popup in an uninitialized split. (#6057) - Bugfix: Fixed an issue where commands would sometimes reset if Chatterino was improperly shut down. (#6011) - Bugfix: Fixed a thick border on Windows 11. (#5836) - Bugfix: Fixed some windows not immediately closing. (#6054) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index d6702ff8..399fd238 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -299,6 +299,7 @@ ChannelView::ChannelView(QWidget *parent, Split *split, Context context, ChannelView::ChannelView(InternalCtor /*tag*/, QWidget *parent, Split *split, Context context, size_t messagesLimit) : BaseWidget(parent) + , channel_(Channel::getEmpty()) , split_(split) , scrollBar_(new Scrollbar(messagesLimit, this)) , highlightAnimation_(this) @@ -903,8 +904,10 @@ LimitedQueueSnapshot &ChannelView::getMessagesSnapshot() return this->snapshot_; } -ChannelPtr ChannelView::channel() +ChannelPtr ChannelView::channel() const { + assert(this->channel_ != nullptr); + return this->channel_; } @@ -3194,10 +3197,7 @@ bool ChannelView::canReplyToMessages() const return false; } - if (this->channel_ == nullptr) - { - return false; - } + assert(this->channel_ != nullptr); if (!this->channel_->isTwitchChannel()) { diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 3c8f078f..c58eee3e 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -145,7 +145,7 @@ public: /// nor IrcChannel. /// It's **not** equal to the channel passed in #setChannel(). /// @see #underlyingChannel() - ChannelPtr channel(); + ChannelPtr channel() const; /// @brief The channel this view displays messages for /// @@ -359,7 +359,7 @@ private: /// screen and will always be a @a Channel, or, it will never be a /// TwitchChannel or IrcChannel, however, it will have the same type and /// name as @a underlyingChannel_. It's not know to any registry/server. - ChannelPtr channel_ = nullptr; + ChannelPtr channel_; /// @brief The channel receiving messages ///