diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-18 06:48:09 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-18 06:48:09 +0200 |
commit | 7e1a950a0be2871045e0dda6ba2adc892d323464 (patch) | |
tree | 90190f3a987ffb1b0fc6d9eaa499766155bb4d32 /src | |
parent | fa4897265ae955872b0c2530300a3110e995510e (diff) |
Fix potential crash in thumbnail loader
Diffstat (limited to 'src')
-rw-r--r-- | src/AsyncImageLoader.cpp | 6 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp index bfef294..fb864c2 100644 --- a/src/AsyncImageLoader.cpp +++ b/src/AsyncImageLoader.cpp @@ -70,6 +70,12 @@ namespace QuickMedia { return ""; } + // TODO: Remove and use std::thread and detach instead of std::async + AsyncImageLoader::~AsyncImageLoader() { + if(load_image_future.valid()) + load_image_future.get(); + } + // TODO: Run in 5 different threads, and add download_to_file(_cache) to reduce memory usage in each (use -O curl option) bool AsyncImageLoader::load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, bool use_tor, std::shared_ptr<ThumbnailData> thumbnail_data) { update(); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 10224e2..13f7db9 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3744,7 +3744,7 @@ namespace QuickMedia { async_image_loader.update(); if(current_room_body_data && room_avatar_thumbnail_data->loading_state == LoadingState::NOT_LOADED) - async_image_loader.load_thumbnail(current_room_body_data->body_item->thumbnail_url, false, sf::Vector2i(), use_tor, room_avatar_thumbnail_data); + async_image_loader.load_thumbnail(current_room_body_data->body_item->thumbnail_url, false, sf::Vector2i(32, 32), use_tor, room_avatar_thumbnail_data); if(room_avatar_thumbnail_data->loading_state == LoadingState::FINISHED_LOADING && room_avatar_thumbnail_data->image->getSize().x > 0 && room_avatar_thumbnail_data->image->getSize().y > 0) { if(!room_avatar_thumbnail_data->texture.loadFromImage(*room_avatar_thumbnail_data->image)) |