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 --- src/Program.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/Program.cpp') diff --git a/src/Program.cpp b/src/Program.cpp index 8b3cc49..5e54971 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -303,6 +303,11 @@ int exec_program_write_stdin(const char **args, const char *str, size_t size, Pr } int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata, int buffer_size) { + int allowed_exit_status[1] = {0}; + return exec_program(args, output_callback, userdata, allowed_exit_status, 1, buffer_size); +} + +int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata, int *allowed_exit_status, int num_allowed_exit_status, int buffer_size) { ReadProgram read_program; int res = exec_program_pipe(args, &read_program); if(res != 0) @@ -311,6 +316,7 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void int result = 0; int status; int exit_status; + bool is_error = true; assert(buffer_size >= 1 && buffer_size <= 65536); char *buffer = (char*)alloca(buffer_size + 1); @@ -349,7 +355,14 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void } exit_status = WEXITSTATUS(status); - if(exit_status != 0) { + for(int i = 0; i < num_allowed_exit_status; ++i) { + if(exit_status == allowed_exit_status[i]) { + is_error = false; + break; + } + } + + if(is_error) { fprintf(stderr, "Failed to execute program ("); const char **arg = args; while(*arg) { @@ -360,6 +373,8 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void } fprintf(stderr, "), exit status %d\n", exit_status); result = -exit_status; + if(result == 0) + result = -1; } cleanup: -- cgit v1.2.3