summaryrefslogtreecommitdiffstats
path: root/editor/plugins/tiles
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-01-22 13:44:36 +0100
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-01-22 13:44:36 +0100
commitdbcd82ba674182fbf5bf5ae0a9701da2b11e6fe9 (patch)
tree8e25d9a631404ef8bc1432f16fbf20b9ebd99b1d /editor/plugins/tiles
parent0bcc0e92b3f0ac57d4c4650722f347593a258572 (diff)
downloadredot-engine-dbcd82ba674182fbf5bf5ae0a9701da2b11e6fe9.tar.gz
[Editor] Fix threading problems with `TileMap` preview
Diffstat (limited to 'editor/plugins/tiles')
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp
index 057e6443d6..65f52bc92c 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.cpp
+++ b/editor/plugins/tiles/tiles_editor_plugin.cpp
@@ -68,6 +68,9 @@ void TilesEditorUtils::_thread_func(void *ud) {
}
void TilesEditorUtils::_thread() {
+ CallQueue queue;
+ MessageQueue::set_thread_singleton_override(&queue);
+
pattern_thread_exited.clear();
while (!pattern_thread_exit.is_set()) {
pattern_preview_sem.wait();
@@ -127,6 +130,8 @@ void TilesEditorUtils::_thread() {
// Add the viewport at the last moment to avoid rendering too early.
callable_mp((Node *)EditorNode::get_singleton(), &Node::add_child).call_deferred(viewport, false, Node::INTERNAL_MODE_DISABLED);
+ MessageQueue::get_singleton()->flush();
+
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorUtils *>(this), &TilesEditorUtils::_preview_frame_started), Object::CONNECT_ONE_SHOT);
pattern_preview_done.wait();
@@ -139,7 +144,11 @@ void TilesEditorUtils::_thread() {
viewport->queue_free();
}
}
+
+ MessageQueue::get_singleton()->flush();
}
+
+ MessageQueue::get_singleton()->flush();
pattern_thread_exited.set();
}