Skip to content

Commit

Permalink
Bugfix: Jobs couldn't add new Jobs during Jobs::step
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Feb 11, 2025
1 parent f7224c8 commit 987f522
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,13 @@ void Window::stepIfNeeded() {
#ifdef JNGL_PERFORMANCE_OVERLAY
auto start = std::chrono::steady_clock::now();
#endif
for (auto& job : jobs) {
job->step();

// use oldschool for loop here, so that Jobs can add other Jobs during step():
const size_t numOfJobs = jobs.size();
for (size_t i = 0; i < numOfJobs; ++i) {
jobs[i]->step();
}

for (auto job : jobsToRemove) {
const auto it = std::find_if(jobs.begin(), jobs.end(),
[job](const auto& p) { return p.get() == job; });
Expand Down

0 comments on commit 987f522

Please sign in to comment.