From bdee9fff70cfb8b953dc1feb3400862c750c7142 Mon Sep 17 00:00:00 2001 From: hemirt Date: Wed, 11 Oct 2017 14:46:56 +0200 Subject: [PATCH] fix image loader scrollbar crash (#129) * fix image loader scrollbar crash --- src/messages/imageloadermanager.cpp | 4 +++- src/messages/imageloadermanager.hpp | 3 +++ src/messages/lazyloadedimage.hpp | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/messages/imageloadermanager.cpp b/src/messages/imageloadermanager.cpp index 735232297..f83521044 100644 --- a/src/messages/imageloadermanager.cpp +++ b/src/messages/imageloadermanager.cpp @@ -43,6 +43,8 @@ void ImageLoaderManager::queue(chatterino::messages::LazyLoadedImage *lli) QObject::connect(&requester, &ImageLoaderRequester::request, worker, &ImageLoaderWorker::handleRequest); + QObject::connect(worker, &ImageLoaderWorker::done, lli, + [lli]() { lli->windowManager.layoutVisibleChatWidgets(); }); emit requester.request(lli, &this->NaM); } @@ -80,9 +82,9 @@ void ImageLoaderWorker::handleLoad(chatterino::messages::LazyLoadedImage *lli, Q } lli->emoteManager.incGeneration(); - lli->windowManager.layoutVisibleChatWidgets(); reply->deleteLater(); + emit this->done(); delete this; } diff --git a/src/messages/imageloadermanager.hpp b/src/messages/imageloadermanager.hpp index 9f0f0250a..4894b538b 100644 --- a/src/messages/imageloadermanager.hpp +++ b/src/messages/imageloadermanager.hpp @@ -15,6 +15,9 @@ class ImageLoaderWorker : public QObject public slots: void handleRequest(chatterino::messages::LazyLoadedImage *lli, QNetworkAccessManager *nam); void handleLoad(LazyLoadedImage *lli, QNetworkReply *reply); + +signals: + void done(); }; class ImageLoaderRequester : public QObject diff --git a/src/messages/lazyloadedimage.hpp b/src/messages/lazyloadedimage.hpp index 50c544589..751ec98e7 100644 --- a/src/messages/lazyloadedimage.hpp +++ b/src/messages/lazyloadedimage.hpp @@ -10,8 +10,6 @@ class WindowManager; namespace messages { -class ImageLoaderManager; - class LazyLoadedImage : public QObject { public: @@ -68,6 +66,7 @@ private: void gifUpdateTimout(); friend class ImageLoaderWorker; + friend class ImageLoaderManager; }; } // namespace messages