Make LimitedQueueSnapshot usages in ChannelView const (#4223)

This commit is contained in:
pajlada 2022-12-07 20:40:15 +01:00 committed by GitHub
parent 9f008f86d2
commit 4fdcac8ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -426,7 +426,7 @@ void ChannelView::performLayout(bool causedByScrollbar)
// BenchmarkGuard benchmark("layout"); // BenchmarkGuard benchmark("layout");
/// Get messages and check if there are at least 1 /// Get messages and check if there are at least 1
auto &messages = this->getMessagesSnapshot(); const auto &messages = this->getMessagesSnapshot();
this->showingLatestMessages_ = this->showingLatestMessages_ =
this->scrollBar_->isAtBottom() || this->scrollBar_->isAtBottom() ||
@ -444,7 +444,7 @@ void ChannelView::performLayout(bool causedByScrollbar)
} }
void ChannelView::layoutVisibleMessages( void ChannelView::layoutVisibleMessages(
LimitedQueueSnapshot<MessageLayoutPtr> &messages) const LimitedQueueSnapshot<MessageLayoutPtr> &messages)
{ {
const auto start = size_t(this->scrollBar_->getCurrentValue()); const auto start = size_t(this->scrollBar_->getCurrentValue());
const auto layoutWidth = this->getLayoutWidth(); const auto layoutWidth = this->getLayoutWidth();
@ -468,11 +468,14 @@ void ChannelView::layoutVisibleMessages(
} }
if (redrawRequired) if (redrawRequired)
{
this->queueUpdate(); this->queueUpdate();
}
} }
void ChannelView::updateScrollbar( void ChannelView::updateScrollbar(
LimitedQueueSnapshot<MessageLayoutPtr> &messages, bool causedByScrollbar) const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
bool causedByScrollbar)
{ {
if (messages.size() == 0) if (messages.size() == 0)
{ {

View file

@ -195,8 +195,8 @@ private:
void performLayout(bool causedByScrollbar = false); void performLayout(bool causedByScrollbar = false);
void layoutVisibleMessages( void layoutVisibleMessages(
LimitedQueueSnapshot<MessageLayoutPtr> &messages); const LimitedQueueSnapshot<MessageLayoutPtr> &messages);
void updateScrollbar(LimitedQueueSnapshot<MessageLayoutPtr> &messages, void updateScrollbar(const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
bool causedByScrollbar); bool causedByScrollbar);
void drawMessages(QPainter &painter); void drawMessages(QPainter &painter);