Skip to content

Commit

Permalink
Merge pull request #50640 from goostengine/add-engine-print-error-pro…
Browse files Browse the repository at this point in the history
…perty-3.x

[3.x] Add `Engine.print_error_messages` property to disable printing errors
  • Loading branch information
akien-mga authored Jul 20, 2021
2 parents d122433 + 726111f commit 028bf84
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,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);
Expand Down Expand Up @@ -2994,7 +3002,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::REAL, "time_scale"), "set_time_scale", "get_time_scale");
Expand Down
3 changes: 3 additions & 0 deletions core/bind/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ class _Engine : public Object {
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();
};

Expand Down
8 changes: 8 additions & 0 deletions core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}

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;
Expand Down
3 changes: 3 additions & 0 deletions core/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class Engine {
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;

void set_print_error_messages(bool p_enabled);
bool is_printing_error_messages() const;

void add_singleton(const Singleton &p_singleton);
void get_singletons(List<Singleton> *p_singletons);
bool has_singleton(const String &p_name) const;
Expand Down
5 changes: 5 additions & 0 deletions doc/classes/Engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
[b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code].
</member>
<member name="print_error_messages" type="bool" setter="set_print_error_messages" getter="is_printing_error_messages" default="true">
If [code]false[/code], stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the [member ProjectSettings.application/run/disable_stderr] project setting.
[b]Warning:[/b] If you set this to [code]false[/code] anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to [code]false[/code] in a [code]@tool[/code] script, this will also impact the editor itself. Do [i]not[/i] report bugs before ensuring error messages are enabled (as they are by default).
[b]Note:[/b] This property does not impact the editor's Errors tab when running a project from the editor.
</member>
<member name="target_fps" type="int" setter="set_target_fps" getter="get_target_fps" default="0">
The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit.
</member>
Expand Down

0 comments on commit 028bf84

Please sign in to comment.