diff options
author | 风青山 <idleman@yeah.net> | 2022-03-16 15:50:48 +0800 |
---|---|---|
committer | Rindbee <idleman@yeah.net> | 2022-08-23 23:25:22 +0800 |
commit | e561c68256452286e610dc60ba963987f31595d1 (patch) | |
tree | 29fe4c54691e6d20d75815dbc8bfae8ea88c82f1 /scene/gui/range.cpp | |
parent | ba0421f3d907b1a3fc94e05f6c20b158e9aa7021 (diff) |
Add some codes, returnes directly if the value is not changed.
Avoid executing the following value-changed logics if the value does not really change.
Diffstat (limited to 'scene/gui/range.cpp')
-rw-r--r-- | scene/gui/range.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index fae6688452..0fb1f27802 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -106,6 +106,10 @@ void Range::set_value(double p_val) { } void Range::set_min(double p_min) { + if (shared->min == p_min) { + return; + } + shared->min = p_min; set_value(shared->val); _validate_values(); @@ -116,6 +120,10 @@ void Range::set_min(double p_min) { } void Range::set_max(double p_max) { + if (shared->max == p_max) { + return; + } + shared->max = p_max; set_value(shared->val); _validate_values(); @@ -124,11 +132,19 @@ void Range::set_max(double p_max) { } void Range::set_step(double p_step) { + if (shared->step == p_step) { + return; + } + shared->step = p_step; shared->emit_changed("step"); } void Range::set_page(double p_page) { + if (shared->page == p_page) { + return; + } + shared->page = p_page; set_value(shared->val); _validate_values(); @@ -300,6 +316,10 @@ bool Range::is_using_rounded_values() const { } void Range::set_exp_ratio(bool p_enable) { + if (shared->exp_ratio == p_enable) { + return; + } + shared->exp_ratio = p_enable; update_configuration_warnings(); |