fix: check if threads are started before waiting

This commit is contained in:
Sara Gerretsen 2026-03-03 16:48:49 +01:00
parent 0f5539ebc0
commit e2207eec68

View file

@ -75,7 +75,9 @@ void Terrain::_notification(int what) {
this->threads_stop = true; this->threads_stop = true;
this->workload_lock.unlock(); this->workload_lock.unlock();
for (Thread &thread : this->threads) { for (Thread &thread : this->threads) {
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
} }
return; return;
} }
@ -115,7 +117,9 @@ void Terrain::construct_chunk_grid() {
this->threads_stop = true; this->threads_stop = true;
this->workload_lock.unlock(); this->workload_lock.unlock();
for (Thread &thread : this->threads) { for (Thread &thread : this->threads) {
thread.wait_to_finish(); if (thread.is_started()) {
thread.wait_to_finish();
}
} }
this->workload_lock.lock(); this->workload_lock.lock();
for (TerrainChunkMesh *mesh : this->meshes) { for (TerrainChunkMesh *mesh : this->meshes) {