Skip to content

Commit

Permalink
fix: crash when callback is uninitialised
Browse files Browse the repository at this point in the history
  • Loading branch information
f0e committed Nov 3, 2024
1 parent 5c436c4 commit 2886c0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ int main(int argc, char* argv[]) {
try {
CLI11_PARSE(app, argc, argv);

printf("Hi\n");

cli::run(inputs, outputs, configPaths, preview, verbose);

return 0;
Expand Down
6 changes: 3 additions & 3 deletions src/common/rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
void c_rendering::render_videos() {
if (!queue.empty()) {
current_render = queue.front();
rendering.progress_callback();
run_callbacks();

try {
current_render->render();
Expand All @@ -19,7 +19,7 @@ void c_rendering::render_videos() {
// finished rendering, delete
queue.erase(queue.begin());
current_render = nullptr;
rendering.progress_callback();
run_callbacks();

renders_queued = !queue.empty();
}
Expand Down Expand Up @@ -287,7 +287,7 @@ bool c_render::do_render(s_render_commands render_commands) {
status.start_time = std::chrono::high_resolution_clock::now();
}

rendering.progress_callback();
rendering.run_callbacks();
}

line.clear();
Expand Down
7 changes: 6 additions & 1 deletion src/common/rendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class c_rendering {
public:
std::vector<std::shared_ptr<c_render>> queue;
std::shared_ptr<c_render> current_render;
std::function<void()> progress_callback;
std::optional<std::function<void()>> progress_callback;
bool renders_queued;

public:
Expand All @@ -86,6 +86,11 @@ class c_rendering {
void queue_render(std::shared_ptr<c_render> render);

void stop_rendering();

void run_callbacks() {
if (progress_callback)
(*progress_callback)();
}
};

inline c_rendering rendering;

0 comments on commit 2886c0a

Please sign in to comment.