mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
graphicbuffers of msgs offscreen get discarded now
This commit is contained in:
parent
6c23925406
commit
9dd6966e8c
2 changed files with 39 additions and 0 deletions
|
@ -473,6 +473,8 @@ void ChannelView::drawMessages(QPainter &painter)
|
|||
int y = -(messagesSnapshot[start].get()->getHeight() *
|
||||
(fmod(this->scrollBar.getCurrentValue(), 1)));
|
||||
|
||||
messages::MessageRef *end = nullptr;
|
||||
|
||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||
messages::MessageRef *messageRef = messagesSnapshot[i].get();
|
||||
|
||||
|
@ -520,10 +522,43 @@ void ChannelView::drawMessages(QPainter &painter)
|
|||
|
||||
y += messageRef->getHeight();
|
||||
|
||||
end = messageRef;
|
||||
if (y > height()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (end == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove messages that are on screen
|
||||
// the messages that are left at the end get their buffers reset
|
||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||
messages::MessageRef *messageRef = messagesSnapshot[i].get();
|
||||
auto it = this->messagesOnScreen.find(messageRef);
|
||||
if (it != this->messagesOnScreen.end()) {
|
||||
this->messagesOnScreen.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// delete the message buffers that aren't on screen
|
||||
for (MessageRef *item : this->messagesOnScreen) {
|
||||
item->buffer.reset();
|
||||
}
|
||||
|
||||
this->messagesOnScreen.clear();
|
||||
|
||||
// add all messages on screen to the map
|
||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||
messages::MessageRef *messageRef = messagesSnapshot[i].get();
|
||||
|
||||
this->messagesOnScreen.insert(messageRef);
|
||||
|
||||
if (messageRef == end) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap *buffer,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QWidget>
|
||||
#include <boost/signals2.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
@ -165,6 +166,9 @@ private:
|
|||
boost::signals2::connection layoutConnection;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
|
||||
std::unordered_set<messages::MessageRef *> messagesOnScreen;
|
||||
|
||||
private slots:
|
||||
void wordTypeMaskChanged()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue