From 0a10f09ce4321695940a626eef9c64b36f599193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 27 Sep 2023 15:17:02 +0200 Subject: [PATCH] Web: Clarify that `OS.get_unique_id` is not supported Remove the base error message in `OS`, we no longer really error out this way for not implemented methods. Instead, each platform should override them to provide the context they want. Fixes #82439. --- core/os/os.cpp | 2 +- doc/classes/OS.xml | 2 +- platform/web/os_web.cpp | 4 ++++ platform/web/os_web.h | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/os/os.cpp b/core/os/os.cpp index 38ea4a0fddd4..991b179e1f8f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -355,7 +355,7 @@ void OS::set_cmdline(const char *p_execpath, const List &p_args, const L } String OS::get_unique_id() const { - ERR_FAIL_V(""); + return ""; } int OS::get_processor_count() const { diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 2efe47a01213..7cfbca117886 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -449,7 +449,7 @@ Returns a string that is unique to the device. [b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes. - [b]Note:[/b] Returns an empty string on Web, as this method isn't implemented on this platform yet. + [b]Note:[/b] Returns an empty string and prints an error on Web, as this method cannot be implemented on this platform. diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp index f038f0248a84..186e4abf92e1 100644 --- a/platform/web/os_web.cpp +++ b/platform/web/os_web.cpp @@ -132,6 +132,10 @@ int OS_Web::get_processor_count() const { return godot_js_os_hw_concurrency_get(); } +String OS_Web::get_unique_id() const { + ERR_FAIL_V_MSG("", "OS::get_unique_id() is not available on the Web platform."); +} + bool OS_Web::_check_internal_feature_support(const String &p_feature) { if (p_feature == "web") { return true; diff --git a/platform/web/os_web.h b/platform/web/os_web.h index b9570f9ca1ab..5335340b7977 100644 --- a/platform/web/os_web.h +++ b/platform/web/os_web.h @@ -83,6 +83,7 @@ class OS_Web : public OS_Unix { int get_process_id() const override; bool is_process_running(const ProcessID &p_pid) const override; int get_processor_count() const override; + String get_unique_id() const override; int get_default_thread_pool_size() const override { return 1; } String get_executable_path() const override;