diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 25 | ||||
-rw-r--r-- | core/core_bind.h | 3 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 2 | ||||
-rw-r--r-- | core/os/os.h | 3 | ||||
-rw-r--r-- | core/os/thread.cpp | 1 |
5 files changed, 12 insertions, 22 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 0da6680a7b..47c75cfa28 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -276,6 +276,10 @@ String _OS::get_environment(const String &p_var) const { return OS::get_singleton()->get_environment(p_var); } +bool _OS::set_environment(const String &p_var, const String &p_value) const { + return OS::get_singleton()->set_environment(p_var, p_value); +} + String _OS::get_name() const { return OS::get_singleton()->get_name(); } @@ -318,18 +322,6 @@ uint64_t _OS::get_static_memory_peak_usage() const { return OS::get_singleton()->get_static_memory_peak_usage(); } -int _OS::get_exit_code() const { - return OS::get_singleton()->get_exit_code(); -} - -void _OS::set_exit_code(int p_code) { - if (p_code < 0 || p_code > 125) { - WARN_PRINT("For portability reasons, the exit code should be set between 0 and 125 (inclusive)."); - } - - OS::get_singleton()->set_exit_code(p_code); -} - /** * Get current datetime with consideration for utc and * dst @@ -711,8 +703,9 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open); ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id); - ClassDB::bind_method(D_METHOD("get_environment", "environment"), &_OS::get_environment); - ClassDB::bind_method(D_METHOD("has_environment", "environment"), &_OS::has_environment); + ClassDB::bind_method(D_METHOD("get_environment", "variable"), &_OS::get_environment); + ClassDB::bind_method(D_METHOD("set_environment", "variable", "value"), &_OS::set_environment); + ClassDB::bind_method(D_METHOD("has_environment", "variable"), &_OS::has_environment); ClassDB::bind_method(D_METHOD("get_name"), &_OS::get_name); ClassDB::bind_method(D_METHOD("get_cmdline_args"), &_OS::get_cmdline_args); @@ -725,9 +718,6 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_datetime_from_unix_time", "unix_time_val"), &_OS::get_datetime_from_unix_time); ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime", "datetime"), &_OS::get_unix_time_from_datetime); - ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code); - ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code); - ClassDB::bind_method(D_METHOD("delay_usec", "usec"), &_OS::delay_usec); ClassDB::bind_method(D_METHOD("delay_msec", "msec"), &_OS::delay_msec); ClassDB::bind_method(D_METHOD("get_ticks_msec"), &_OS::get_ticks_msec); @@ -772,7 +762,6 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("request_permissions"), &_OS::request_permissions); ClassDB::bind_method(D_METHOD("get_granted_permissions"), &_OS::get_granted_permissions); - ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec"); diff --git a/core/core_bind.h b/core/core_bind.h index 8a4885b82b..3920116ca4 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -172,6 +172,7 @@ public: bool has_environment(const String &p_var) const; String get_environment(const String &p_var) const; + bool set_environment(const String &p_var, const String &p_value) const; String get_name() const; Vector<String> get_cmdline_args(); @@ -198,8 +199,6 @@ public: void set_use_file_access_save_and_swap(bool p_enable); - int get_exit_code() const; - void set_exit_code(int p_code); Dictionary get_date(bool utc) const; Dictionary get_time(bool utc) const; Dictionary get_datetime(bool utc) const; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 3c84e6b656..343adbe592 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -92,7 +92,7 @@ private: PathMD5() {} - PathMD5(const Vector<uint8_t> p_buf) { + PathMD5(const Vector<uint8_t> &p_buf) { a = *((uint64_t *)&p_buf[0]); b = *((uint64_t *)&p_buf[8]); } diff --git a/core/os/os.h b/core/os/os.h index 77a54ba68a..e41d788e12 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -40,6 +40,7 @@ #include "core/templates/vector.h" #include <stdarg.h> +#include <stdlib.h> class OS { static OS *singleton; @@ -53,7 +54,7 @@ class OS { bool _debug_stdout = false; String _local_clipboard; bool _no_window = false; - int _exit_code = 0; + int _exit_code = EXIT_FAILURE; // unexpected exit is marked as failure int _orientation; bool _allow_hidpi = false; bool _allow_layered = false; diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 88744eed63..aea370787d 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -92,6 +92,7 @@ bool Thread::is_started() const { void Thread::wait_to_finish() { if (id != 0) { + ERR_FAIL_COND_MSG(id == get_caller_id(), "A Thread can't wait for itself to finish."); thread.join(); std::thread empty_thread; thread.swap(empty_thread); |