mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #78000 from RandomShaper/let_users_mess_up
Let user scripts disable thread safety checks
This commit is contained in:
commit
37d1dfef9d
6 changed files with 27 additions and 2 deletions
|
@ -39,6 +39,7 @@
|
|||
#include "core/math/geometry_2d.h"
|
||||
#include "core/math/geometry_3d.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
namespace core_bind {
|
||||
|
@ -1259,6 +1260,11 @@ Variant Thread::wait_to_finish() {
|
|||
return r;
|
||||
}
|
||||
|
||||
void Thread::set_thread_safety_checks_enabled(bool p_enabled) {
|
||||
ERR_FAIL_COND_MSG(::Thread::is_main_thread(), "This call is forbidden on the main thread.");
|
||||
set_current_thread_safe_for_nodes(!p_enabled);
|
||||
}
|
||||
|
||||
void Thread::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("start", "callable", "priority"), &Thread::start, DEFVAL(PRIORITY_NORMAL));
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &Thread::get_id);
|
||||
|
@ -1266,6 +1272,8 @@ void Thread::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_alive"), &Thread::is_alive);
|
||||
ClassDB::bind_method(D_METHOD("wait_to_finish"), &Thread::wait_to_finish);
|
||||
|
||||
ClassDB::bind_static_method("Thread", D_METHOD("set_thread_safety_checks_enabled", "enabled"), &Thread::set_thread_safety_checks_enabled);
|
||||
|
||||
BIND_ENUM_CONSTANT(PRIORITY_LOW);
|
||||
BIND_ENUM_CONSTANT(PRIORITY_NORMAL);
|
||||
BIND_ENUM_CONSTANT(PRIORITY_HIGH);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue