From 7e1a950a0be2871045e0dda6ba2adc892d323464 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 18 Oct 2020 06:48:09 +0200 Subject: Fix potential crash in thumbnail loader --- src/AsyncImageLoader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/AsyncImageLoader.cpp') 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 thumbnail_data) { update(); -- cgit v1.2.3