From f3e48c13253ed345d8d71d9e3edb074d371ff42f Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 21 Aug 2019 00:01:27 +0200 Subject: [PATCH] smoll changes --- lib/appbase/widgets/BaseWindow.cpp | 2 -- src/common/NetworkPrivate.cpp | 10 +++++----- src/common/NetworkPrivate.hpp | 4 ++-- src/common/NetworkRequest.cpp | 10 +++++----- src/messages/Image.cpp | 4 ++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/appbase/widgets/BaseWindow.cpp b/lib/appbase/widgets/BaseWindow.cpp index 43f94d65..039e8fbf 100644 --- a/lib/appbase/widgets/BaseWindow.cpp +++ b/lib/appbase/widgets/BaseWindow.cpp @@ -643,8 +643,6 @@ void BaseWindow::drawCustomWindowFrame(QPainter &painter) #ifdef USEWINSDK if (this->hasCustomWindowFrame()) { - QPainter painter(this); - QColor bg = this->overrideBackgroundColor_.value_or( this->theme->window.background); diff --git a/src/common/NetworkPrivate.cpp b/src/common/NetworkPrivate.cpp index cce72cbc..42b73ae0 100644 --- a/src/common/NetworkPrivate.cpp +++ b/src/common/NetworkPrivate.cpp @@ -55,7 +55,7 @@ QString NetworkData::getHash() void writeToCache(const std::shared_ptr &data, const QByteArray &bytes) { - if (data->useQuickLoadCache_) + if (data->cache_) { QtConcurrent::run([data, bytes] { QFile cachedFile(getPaths()->cacheDirectory() + "/" + @@ -155,7 +155,7 @@ void loadUncached(const std::shared_ptr &data) // log("starting {}", data->request_.url().toString()); if (data->onSuccess_) { - if (data->executeConcurrently) + if (data->executeConcurrently_) QtConcurrent::run( [onSuccess = std::move(data->onSuccess_), result = std::move(result)] { onSuccess(result); }); @@ -170,7 +170,7 @@ void loadUncached(const std::shared_ptr &data) QObject::connect( reply, &QNetworkReply::finished, worker, [data, handleReply, worker]() mutable { - if (data->executeConcurrently || isGuiThread()) + if (data->executeConcurrently_ || isGuiThread()) { handleReply(); delete worker; @@ -211,7 +211,7 @@ void loadCached(const std::shared_ptr &data) if (data->onSuccess_) { - if (data->executeConcurrently || isGuiThread()) + if (data->executeConcurrently_ || isGuiThread()) { // XXX: If outcome is Failure, we should invalidate the cache file // somehow/somewhere @@ -239,7 +239,7 @@ void loadCached(const std::shared_ptr &data) void load(const std::shared_ptr &data) { - if (data->useQuickLoadCache_) + if (data->cache_) { QtConcurrent::run(loadCached, data); loadCached(data); diff --git a/src/common/NetworkPrivate.hpp b/src/common/NetworkPrivate.hpp index e951108a..be08a7ea 100644 --- a/src/common/NetworkPrivate.hpp +++ b/src/common/NetworkPrivate.hpp @@ -35,8 +35,8 @@ struct NetworkData { QNetworkRequest request_; bool hasCaller_{}; QObjectRef caller_; - bool useQuickLoadCache_{}; - bool executeConcurrently{}; + bool cache_{}; + bool executeConcurrently_{}; NetworkReplyCreatedCallback onReplyCreated_; NetworkErrorCallback onError_; diff --git a/src/common/NetworkRequest.cpp b/src/common/NetworkRequest.cpp index d9ba3c3e..b0475bd6 100644 --- a/src/common/NetworkRequest.cpp +++ b/src/common/NetworkRequest.cpp @@ -109,7 +109,7 @@ NetworkRequest NetworkRequest::timeout(int ms) && NetworkRequest NetworkRequest::concurrent() && { - this->data->executeConcurrently = true; + this->data->executeConcurrently_ = true; return std::move(*this); } @@ -135,7 +135,7 @@ NetworkRequest NetworkRequest::payload(const QByteArray &payload) && NetworkRequest NetworkRequest::cache() && { - this->data->useQuickLoadCache_ = true; + this->data->cache_ = true; return std::move(*this); } @@ -144,15 +144,15 @@ void NetworkRequest::execute() this->executed_ = true; // Only allow caching for GET request - if (this->data->useQuickLoadCache_ && + if (this->data->cache_ && this->data->requestType_ != NetworkRequestType::Get) { qDebug() << "Can only cache GET requests!"; - this->data->useQuickLoadCache_ = false; + this->data->cache_ = false; } // Can not have a caller and be concurrent at the same time. - assert(!(this->data->caller_ && this->data->executeConcurrently)); + assert(!(this->data->caller_ && this->data->executeConcurrently_)); load(std::move(this->data)); } diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 1b9c0258..3a348a82 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -337,7 +337,7 @@ void Image::load() NetworkRequest(this->url().string) .concurrent() .cache() - .onSuccess([that = this, weak = weakOf(this)](auto result) -> Outcome { + .onSuccess([weak = weakOf(this)](auto result) -> Outcome { auto shared = weak.lock(); if (!shared) return Failure; @@ -348,7 +348,7 @@ void Image::load() QBuffer buffer(const_cast(&data)); buffer.open(QIODevice::ReadOnly); QImageReader reader(&buffer); - auto parsed = detail::readFrames(reader, that->url()); + auto parsed = detail::readFrames(reader, shared->url()); postToThread(makeConvertCallback(parsed, [weak](auto frames) { if (auto shared = weak.lock())