From bf6bebb0aa73e48776e1664abe071624ffa010c1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 14 Oct 2015 21:15:46 +0200 Subject: [PATCH] fixed bug in history size count, 0.9.5 --- Telegram/SourceFiles/app.cpp | 2 +- Telegram/SourceFiles/history.cpp | 6 +++--- Telegram/SourceFiles/history.h | 10 ++++------ Telegram/SourceFiles/mainwidget.cpp | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 44067891dc..748fdbfc8a 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -763,7 +763,7 @@ namespace App { } } - existing->updateMedia(m.has_media() ? (&m.vmedia) : 0); + existing->updateMedia(m.has_media() ? (&m.vmedia) : 0, true); existing->setViewsCount(m.has_views() ? m.vviews.v : -1); } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 6adc05a8f9..27a5ed300e 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -1345,7 +1345,7 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo } if (msg.type() == mtpc_message) { - existing->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0); + existing->updateMedia(msg.c_message().has_media() ? (&msg.c_message().vmedia) : 0, (block ? false : true)); } return (returnExisting || regged) ? existing : 0; } @@ -6259,7 +6259,7 @@ HistoryMedia *HistoryMessage::getMedia(bool inOverview) const { return _media; } -void HistoryMessage::setMedia(const MTPMessageMedia *media) { +void HistoryMessage::setMedia(const MTPMessageMedia *media, bool allowEmitResize) { if ((!_media || _media->isImageLink()) && (!media || media->type() == mtpc_messageMediaEmpty)) return; bool mediaWasDisplayed = false; @@ -6280,7 +6280,7 @@ void HistoryMessage::setMedia(const MTPMessageMedia *media) { _textHeight = 0; } initDimensions(); - if (App::main()) App::main()->itemResized(this); + if (allowEmitResize && App::main()) App::main()->itemResized(this); } void HistoryMessage::setText(const QString &text, const LinksInText &links) { diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index b990f358a7..810724759a 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -880,7 +880,7 @@ public: virtual bool serviceMsg() const { return false; } - virtual void updateMedia(const MTPMessageMedia *media) { + virtual void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) { } virtual QString selectedText(uint32 selection) const { @@ -930,8 +930,6 @@ public: virtual HistoryMedia *getMedia(bool inOverview = false) const { return 0; } - virtual void setMedia(const MTPMessageMedia *media) { - } virtual void setText(const QString &text, const LinksInText &links) { } virtual void getTextWithLinks(QString &text, LinksInText &links) { @@ -1541,11 +1539,11 @@ public: QString notificationHeader() const; QString notificationText() const; - void updateMedia(const MTPMessageMedia *media) { + void updateMedia(const MTPMessageMedia *media, bool allowEmitResize) { if (media && _media && _media->type() != MediaTypeWebPage) { _media->updateFrom(*media); } else { - setMedia(media); + setMedia(media, allowEmitResize); } } @@ -1553,7 +1551,7 @@ public: LinksInText textLinks() const; QString inDialogsText() const; HistoryMedia *getMedia(bool inOverview = false) const; - void setMedia(const MTPMessageMedia *media); + void setMedia(const MTPMessageMedia *media, bool allowEmitResize); void setText(const QString &text, const LinksInText &links); void getTextWithLinks(QString &text, LinksInText &links); bool textHasLinks(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index d84143ec49..2dc54ce2b4 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -4169,7 +4169,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { } } - item->updateMedia(d.has_media() ? (&d.vmedia) : 0); + item->updateMedia(d.has_media() ? (&d.vmedia) : 0, true); } } }