Merge pull request #55614 from Calinou/add-os-crash-method-3.x

This commit is contained in:
Rémi Verschelde 2021-12-06 17:04:14 +01:00 committed by GitHub
commit 0845f20784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -1182,6 +1182,10 @@ void _OS::alert(const String &p_alert, const String &p_title) {
OS::get_singleton()->alert(p_alert, p_title); OS::get_singleton()->alert(p_alert, p_title);
} }
void _OS::crash(const String &p_message) {
CRASH_NOW_MSG(p_message);
}
bool _OS::request_permission(const String &p_name) { bool _OS::request_permission(const String &p_name) {
return OS::get_singleton()->request_permission(p_name); return OS::get_singleton()->request_permission(p_name);
} }
@ -1399,6 +1403,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_file_access_save_and_swap", "enabled"), &_OS::set_use_file_access_save_and_swap); ClassDB::bind_method(D_METHOD("set_use_file_access_save_and_swap", "enabled"), &_OS::set_use_file_access_save_and_swap);
ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!")); ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!"));
ClassDB::bind_method(D_METHOD("crash", "message"), &_OS::crash);
ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name); ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name);
ClassDB::bind_method(D_METHOD("get_thread_caller_id"), &_OS::get_thread_caller_id); ClassDB::bind_method(D_METHOD("get_thread_caller_id"), &_OS::get_thread_caller_id);

View file

@ -356,6 +356,7 @@ public:
String get_cache_dir() const; String get_cache_dir() const;
void alert(const String &p_alert, const String &p_title = "ALERT!"); void alert(const String &p_alert, const String &p_title = "ALERT!");
void crash(const String &p_message);
void set_screen_orientation(ScreenOrientation p_orientation); void set_screen_orientation(ScreenOrientation p_orientation);
ScreenOrientation get_screen_orientation() const; ScreenOrientation get_screen_orientation() const;

View file

@ -43,6 +43,13 @@
[b]Note:[/b] This method is implemented on Linux, macOS and Windows. [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
</description> </description>
</method> </method>
<method name="crash">
<return type="void" />
<argument index="0" name="message" type="String" />
<description>
Crashes the engine (or the editor if called within a [code]tool[/code] script). This should [i]only[/i] be used for testing the system's crash handler, not for any other purpose. For general error reporting, use (in order of preference) [method @GDScript.assert], [method @GDScript.push_error] or [method alert]. See also [method kill].
</description>
</method>
<method name="delay_msec" qualifiers="const"> <method name="delay_msec" qualifiers="const">
<return type="void" /> <return type="void" />
<argument index="0" name="msec" type="int" /> <argument index="0" name="msec" type="int" />
@ -714,7 +721,7 @@
<return type="int" enum="Error" /> <return type="int" enum="Error" />
<argument index="0" name="pid" type="int" /> <argument index="0" name="pid" type="int" />
<description> <description>
Kill (terminate) the process identified by the given process ID ([code]pid[/code]), e.g. the one returned by [method execute] in non-blocking mode. Kill (terminate) the process identified by the given process ID ([code]pid[/code]), e.g. the one returned by [method execute] in non-blocking mode. See also [method crash].
[b]Note:[/b] This method can also be used to kill processes that were not spawned by the game. [b]Note:[/b] This method can also be used to kill processes that were not spawned by the game.
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
</description> </description>