aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/AsyncImageLoader.hpp5
-rw-r--r--src/AsyncImageLoader.cpp8
2 files changed, 5 insertions, 8 deletions
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp
index 42e7915..2d083b5 100644
--- a/include/AsyncImageLoader.hpp
+++ b/include/AsyncImageLoader.hpp
@@ -25,9 +25,8 @@ namespace QuickMedia {
LoadingState loading_state = LoadingState::NOT_LOADED;
mgl::Texture texture;
std::unique_ptr<mgl::Image> image; // Set in another thread. This should be .reset after loading it into |texture|, to save memory
- size_t counter = 0;
+ uint32_t counter = 0;
Path thumbnail_path;
- std::string url;
};
struct ThumbnailLoadData {
@@ -91,6 +90,6 @@ namespace QuickMedia {
AsyncTask<void> load_threads[NUM_IMAGE_LOAD_PARALLEL];
MessageQueue<ThumbnailLoadData> image_thumbnail_create_queue;
std::unordered_map<std::string, std::shared_ptr<ThumbnailData>> thumbnails;
- size_t counter = 0;
+ uint32_t counter = 0;
};
}
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp
index 4fe7f0d..95bc9ca 100644
--- a/src/AsyncImageLoader.cpp
+++ b/src/AsyncImageLoader.cpp
@@ -315,10 +315,8 @@ namespace QuickMedia {
// TODO: Instead of generating a new hash everytime to access thumbnail, cache the hash of the thumbnail url.
// TODO: Cache this resize_url
auto &thumbnail_data = thumbnails[url + "_" + std::to_string(resize_target_size.x) + "x" + std::to_string(resize_target_size.y)];
- if(!thumbnail_data) {
+ if(!thumbnail_data)
thumbnail_data = std::make_shared<ThumbnailData>();
- thumbnail_data->url = url;
- }
thumbnail_data->counter = counter;
if(thumbnail_data->thumbnail_path.data.empty()) {
@@ -361,7 +359,7 @@ namespace QuickMedia {
if(download.read_program.pid == -1)
continue;
- if(download.url == it->second->url) {
+ if(download.thumbnail_data.get() == it->second.get()) {
reset_download(download);
break;
}
@@ -369,7 +367,7 @@ namespace QuickMedia {
}
image_thumbnail_create_queue.erase_if([&it](ThumbnailLoadData &load_data) {
- return load_data.path.data == it->second->url;
+ return load_data.thumbnail_data.get() == it->second.get();
});
it = thumbnails.erase(it);