From 442fc29582b5581111e3ffd286f4f3d282877f3c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 16 Dec 2022 21:13:38 +0100 Subject: Fix bug where image are not removed from loading when not visible Matrix: fix invites not showing notification --- include/AsyncImageLoader.hpp | 1 + include/FileAnalyzer.hpp | 3 +++ include/MessageQueue.hpp | 10 +++++++--- include/Program.hpp | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp index 986430c..42e7915 100644 --- a/include/AsyncImageLoader.hpp +++ b/include/AsyncImageLoader.hpp @@ -27,6 +27,7 @@ namespace QuickMedia { std::unique_ptr image; // Set in another thread. This should be .reset after loading it into |texture|, to save memory size_t counter = 0; Path thumbnail_path; + std::string url; }; struct ThumbnailLoadData { diff --git a/include/FileAnalyzer.hpp b/include/FileAnalyzer.hpp index 7be154f..ed17140 100644 --- a/include/FileAnalyzer.hpp +++ b/include/FileAnalyzer.hpp @@ -43,6 +43,9 @@ namespace QuickMedia { bool is_video_ext(const char *ext); bool is_music_ext(const char *ext); + // Set |width| or |height| to 0 to disable scaling. + // TODO: Make this async + bool video_get_start_frame(const FileAnalyzer &file, const char *destination_path, int width = 0, int height = 0); // Set |width| or |height| to 0 to disable scaling. // TODO: Make this async bool video_get_middle_frame(const FileAnalyzer &file, const char *destination_path, int width = 0, int height = 0); diff --git a/include/MessageQueue.hpp b/include/MessageQueue.hpp index ba28431..1e48102 100644 --- a/include/MessageQueue.hpp +++ b/include/MessageQueue.hpp @@ -59,14 +59,18 @@ namespace QuickMedia { } // Return true from |callback| to remove the element - void erase_if(std::function callback) { + int erase_if(std::function callback) { std::unique_lock lock(mutex); + int removed = 0; for(auto it = data_queue.begin(); it != data_queue.end();) { - if(callback(*it)) + if(callback(*it)) { it = data_queue.erase(it); - else + ++removed; + } else { ++it; + } } + return removed; } bool is_running() const { diff --git a/include/Program.hpp b/include/Program.hpp index 674c834..5249de6 100644 --- a/include/Program.hpp +++ b/include/Program.hpp @@ -33,6 +33,7 @@ int exec_program_write_stdin(const char **args, const char *str, size_t size, Pr |buffer_size| has to be between 1 and 65536. */ int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata, int buffer_size = 16384); +int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata, int *allowed_exit_status, int num_allowed_exit_status, int buffer_size = 16384); // Return the exit status, or a negative value if waiting failed int wait_program(pid_t process_id); -- cgit v1.2.3