diff --git a/src/messages/image.cpp b/src/messages/image.cpp index 0561c6b9c..6a235ddf5 100644 --- a/src/messages/image.cpp +++ b/src/messages/image.cpp @@ -19,6 +19,8 @@ namespace chatterino { namespace messages { +bool Image::loadedEventQueued = false; + Image::Image(const QString &url, qreal scale, const QString &name, const QString &tooltip, const QMargins &margin, bool isHat) : url(url) @@ -63,7 +65,7 @@ void Image::loadImage() util::NetworkRequest req(this->getUrl()); req.setCaller(this); req.setUseQuickLoadCache(true); - req.get([lli = this](QByteArray bytes) -> bool { + req.get([lli = this](QByteArray bytes)->bool { QByteArray copy = QByteArray::fromRawData(bytes.constData(), bytes.length()); QBuffer buffer(©); buffer.open(QIODevice::ReadOnly); @@ -131,8 +133,14 @@ void Image::loadImage() singletons::EmoteManager::getInstance().incGeneration(); - util::postToThread( - [] { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); }); + if (!loadedEventQueued) { + loadedEventQueued = true; + + QTimer::singleShot(750, [] { + singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); + loadedEventQueued = false; + }); + } return true; }); diff --git a/src/messages/image.hpp b/src/messages/image.hpp index 0203eca22..b3966ffdd 100644 --- a/src/messages/image.hpp +++ b/src/messages/image.hpp @@ -40,6 +40,8 @@ private: int duration; }; + static bool loadedEventQueued; + QPixmap *currentPixmap = nullptr; QPixmap *loadedPixmap = nullptr; std::vector allFrames;