diff --git a/src/messages/image.cpp b/src/messages/image.cpp index 57c09062a..c07ef71bd 100644 --- a/src/messages/image.cpp +++ b/src/messages/image.cpp @@ -75,6 +75,15 @@ void Image::loadImage() bool first = true; + // clear stuff before loading the image again + lli->allFrames.clear(); + if (lli->isAnimated()) { + util::DebugCount::decrease("animated images"); + } + if (lli->isLoaded) { + util::DebugCount::decrease("loaded images"); + } + for (int index = 0; index < reader.imageCount(); ++index) { if (reader.read(&image)) { auto pixmap = new QPixmap(QPixmap::fromImage(image)); diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index eca39b64d..48bac932e 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -147,6 +147,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection this->buffer = std::shared_ptr(pixmap); this->bufferValid = false; + util::DebugCount::increase("message drawing buffers"); } if (!this->bufferValid || !selection.isEmpty()) { @@ -221,7 +222,11 @@ void MessageLayout::invalidateBuffer() void MessageLayout::deleteBuffer() { - this->buffer = nullptr; + if (this->buffer != nullptr) { + util::DebugCount::decrease("message drawing buffers"); + + this->buffer = nullptr; + } } // Elements diff --git a/src/messages/layouts/messagelayoutelement.cpp b/src/messages/layouts/messagelayoutelement.cpp index 0d4d6b1aa..61147a098 100644 --- a/src/messages/layouts/messagelayoutelement.cpp +++ b/src/messages/layouts/messagelayoutelement.cpp @@ -105,6 +105,7 @@ void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset) } if (this->image->isAnimated()) { + // qDebug() << this->image->getUrl(); auto pixmap = this->image->getPixmap(); if (pixmap != nullptr) {