You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Flushes commands just before the navigation server is destroyed
This commit is contained in:
@@ -121,6 +121,7 @@ GdNavigationServer::GdNavigationServer() :
|
||||
}
|
||||
|
||||
GdNavigationServer::~GdNavigationServer() {
|
||||
flush_queries();
|
||||
memdelete(operations_mutex);
|
||||
memdelete(commands_mutex);
|
||||
}
|
||||
@@ -474,12 +475,9 @@ void GdNavigationServer::set_active(bool p_active) const {
|
||||
mut_this->operations_mutex->unlock();
|
||||
}
|
||||
|
||||
void GdNavigationServer::step(real_t p_delta_time) {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
// With c++ we can't be 100% sure this is called in single thread so use the mutex.
|
||||
void GdNavigationServer::flush_queries() {
|
||||
// In c++ we can't be sure that this is performed in the main thread
|
||||
// even with mutable functions.
|
||||
commands_mutex->lock();
|
||||
operations_mutex->lock();
|
||||
for (size_t i(0); i < commands.size(); i++) {
|
||||
@@ -489,13 +487,24 @@ void GdNavigationServer::step(real_t p_delta_time) {
|
||||
commands.clear();
|
||||
operations_mutex->unlock();
|
||||
commands_mutex->unlock();
|
||||
}
|
||||
|
||||
// These are internal operations so don't need to be shielded.
|
||||
void GdNavigationServer::process(real_t p_delta_time) {
|
||||
flush_queries();
|
||||
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In c++ we can't be sure that this is performed in the main thread
|
||||
// even with mutable functions.
|
||||
operations_mutex->lock();
|
||||
for (int i(0); i < active_maps.size(); i++) {
|
||||
active_maps[i]->sync();
|
||||
active_maps[i]->step(p_delta_time);
|
||||
active_maps[i]->dispatch_callbacks();
|
||||
}
|
||||
operations_mutex->unlock();
|
||||
}
|
||||
|
||||
#undef COMMAND_1
|
||||
|
||||
Reference in New Issue
Block a user