mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Merge pull request #88916 from AThousandShips/tile_thread_fix_4_2
[4.2] Prevent threading problems in `TileMap`
This commit is contained in:
@@ -3023,6 +3023,8 @@ void TileMap::_notification(int p_what) {
|
||||
for (Ref<TileMapLayer> &layer : layers) {
|
||||
layer->notify_tile_map_change(TileMapLayer::DIRTY_FLAGS_TILE_MAP_IN_TREE);
|
||||
}
|
||||
// Update on exit to prevent threading problems.
|
||||
_internal_update();
|
||||
} break;
|
||||
|
||||
case TileMap::NOTIFICATION_ENTER_CANVAS: {
|
||||
@@ -3035,6 +3037,8 @@ void TileMap::_notification(int p_what) {
|
||||
for (Ref<TileMapLayer> &layer : layers) {
|
||||
layer->notify_tile_map_change(TileMapLayer::DIRTY_FLAGS_TILE_MAP_IN_CANVAS);
|
||||
}
|
||||
// Update on exit to prevent threading problems.
|
||||
_internal_update();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_DRAW: {
|
||||
@@ -3109,8 +3113,11 @@ void TileMap::queue_internal_update() {
|
||||
if (pending_update) {
|
||||
return;
|
||||
}
|
||||
pending_update = true;
|
||||
callable_mp(this, &TileMap::_internal_update).call_deferred();
|
||||
// Don't update when outside the tree, it doesn't do anything useful, and causes threading problems.
|
||||
if (is_inside_tree()) {
|
||||
pending_update = true;
|
||||
callable_mp(this, &TileMap::_internal_update).call_deferred();
|
||||
}
|
||||
}
|
||||
|
||||
void TileMap::_internal_update() {
|
||||
|
||||
Reference in New Issue
Block a user