summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2021-05-01 23:09:48 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2021-05-01 23:11:08 +0200
commit0eb9b414c13a67203b0d1cc5bd878afe63d3676b (patch)
treedaa264c3bb88191dc890cb39f957f48d221220cb /core
parent33a0fb6e02ce9ee5d2fe97377a3ec84591b59f7c (diff)
Add `Engine.print_error_messages` property to disable printing errors
This can be used during unit test suite runs to hide error and warning messages. Care should be taken when using this feature, as it can hide important information if used wrongly.
Diffstat (limited to 'core')
-rw-r--r--core/config/engine.cpp8
-rw-r--r--core/config/engine.h3
-rw-r--r--core/core_bind.cpp12
-rw-r--r--core/core_bind.h3
4 files changed, 26 insertions, 0 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index 2360d66438..02a183cef5 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -189,6 +189,14 @@ bool Engine::is_validation_layers_enabled() const {
return use_validation_layers;
}
+void Engine::set_print_error_messages(bool p_enabled) {
+ _print_error_enabled = p_enabled;
+}
+
+bool Engine::is_printing_error_messages() const {
+ return _print_error_enabled;
+}
+
void Engine::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
diff --git a/core/config/engine.h b/core/config/engine.h
index a9080e3dfd..85a8884a05 100644
--- a/core/config/engine.h
+++ b/core/config/engine.h
@@ -98,6 +98,9 @@ public:
void set_time_scale(float p_scale);
float get_time_scale() const;
+ void set_print_error_messages(bool p_enabled);
+ bool is_printing_error_messages() const;
+
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 84d8d0d4d3..bcc1cd484f 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -2321,6 +2321,14 @@ bool _Engine::is_editor_hint() const {
return Engine::get_singleton()->is_editor_hint();
}
+void _Engine::set_print_error_messages(bool p_enabled) {
+ Engine::get_singleton()->set_print_error_messages(p_enabled);
+}
+
+bool _Engine::is_printing_error_messages() const {
+ return Engine::get_singleton()->is_printing_error_messages();
+}
+
void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
@@ -2355,7 +2363,11 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &_Engine::set_editor_hint);
ClassDB::bind_method(D_METHOD("is_editor_hint"), &_Engine::is_editor_hint);
+ ClassDB::bind_method(D_METHOD("set_print_error_messages", "enabled"), &_Engine::set_print_error_messages);
+ ClassDB::bind_method(D_METHOD("is_printing_error_messages"), &_Engine::is_printing_error_messages);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "print_error_messages"), "set_print_error_messages", "is_printing_error_messages");
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_scale"), "set_time_scale", "get_time_scale");
diff --git a/core/core_bind.h b/core/core_bind.h
index 3920116ca4..9fc9e8a39e 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -660,6 +660,9 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
+ void set_print_error_messages(bool p_enabled);
+ bool is_printing_error_messages() const;
+
_Engine() { singleton = this; }
};