aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Program.c13
-rw-r--r--src/QuickMedia.cpp8
2 files changed, 14 insertions, 7 deletions
diff --git a/src/Program.c b/src/Program.c
index fc80e5e..a82bcd2 100644
--- a/src/Program.c
+++ b/src/Program.c
@@ -74,14 +74,20 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
int err = errno;
fprintf(stderr, "Failed to read from pipe to program %s, error: %s\n", args[0], strerror(err));
result = -err;
- goto cleanup;
+ break;
}
buffer[bytes_read] = '\0';
- if(output_callback && output_callback(buffer, bytes_read, userdata) != 0)
- break;
+ if(output_callback) {
+ result = output_callback(buffer, bytes_read, userdata);
+ if(result != 0)
+ break;
+ }
}
+ if(result != 0)
+ kill(read_program.pid, SIGTERM);
+
if(waitpid(read_program.pid, &status, 0) == -1) {
perror("waitpid failed");
result = -5;
@@ -105,7 +111,6 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
}
fprintf(stderr, "), exit status %d\n", exit_status);
result = -exit_status;
- goto cleanup;
}
cleanup:
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 7840326..48d3689 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1059,9 +1059,11 @@ namespace QuickMedia {
} else {
page_loop(std::move(new_tabs));
tabs[selected_tab].page->on_navigate_to_page();
- const Json::Value &chapters_json = content_storage_json["chapters"];
- if(chapters_json.isObject())
- json_chapters = &chapters_json;
+ if(content_storage_json.isObject()) {
+ const Json::Value &chapters_json = content_storage_json["chapters"];
+ if(chapters_json.isObject())
+ json_chapters = &chapters_json;
+ }
}
} else {
// TODO: Show the exact cause of error (get error message from curl).