Revert "Make it repaint after downloading the image"

This reverts commit a56d6b084c.
This commit is contained in:
Mm2PL 2024-05-14 14:58:58 +02:00
parent 04c14a7792
commit 02fc3662d7
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 2 additions and 25 deletions

View file

@ -24,7 +24,6 @@
#include <functional>
#include <queue>
#include <thread>
#include <utility>
// Duration between each check of every Image instance
const auto IMAGE_POOL_CLEANUP_INTERVAL = std::chrono::minutes(1);
@ -428,7 +427,7 @@ bool Image::loaded() const
return this->frames_->current().has_value();
}
std::optional<QPixmap> Image::pixmapOrLoad(std::function<void()> cb)
std::optional<QPixmap> Image::pixmapOrLoad() const
{
assertInGuiThread();
@ -437,10 +436,6 @@ std::optional<QPixmap> Image::pixmapOrLoad(std::function<void()> cb)
// See src/messages/layouts/MessageLayoutElement.cpp ImageLayoutElement::paint, for example.
this->lastUsed_ = std::chrono::steady_clock::now();
if (cb != nullptr)
{
this->finishedLoadingCb_ = std::move(cb);
}
this->load();
return this->frames_->current();
@ -583,20 +578,6 @@ void Image::actuallyLoad()
return true;
})
.finally([weak]() {
postToThread([weak]() {
auto shared = weak.lock();
if (!shared)
{
return;
}
if (shared->finishedLoadingCb_ != nullptr)
{
shared->finishedLoadingCb_();
}
});
})
.execute();
}

View file

@ -2,7 +2,6 @@
#include "common/Aliases.hpp"
#include "common/Common.hpp"
#include "common/network/NetworkResult.hpp"
#include <boost/variant.hpp>
#include <pajlada/signals/signal.hpp>
@ -14,7 +13,6 @@
#include <atomic>
#include <chrono>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
@ -83,7 +81,7 @@ public:
const Url &url() const;
bool loaded() const;
// either returns the current pixmap, or triggers loading it (lazy loading)
std::optional<QPixmap> pixmapOrLoad(std::function<void()> cb = nullptr);
std::optional<QPixmap> pixmapOrLoad() const;
void load() const;
qreal scale() const;
bool isEmpty() const;
@ -120,8 +118,6 @@ private:
// gui thread only
std::unique_ptr<detail::Frames> frames_{};
std::function<void()> finishedLoadingCb_;
friend class ImageExpirationPool;
};