Merge pull request #83925 from jsjtxietian/fix-timer-error-when-base-button-leave-tree-and-feedback

Fix BaseButton `shortcut_feedback`'s timer will raise error when the button is removed from the scene tree
This commit is contained in:
Rémi Verschelde 2023-10-26 08:58:22 +02:00
commit e566167b48
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -380,7 +380,7 @@ void BaseButton::shortcut_input(const Ref<InputEvent> &p_event) {
queue_redraw(); queue_redraw();
accept_event(); accept_event();
if (shortcut_feedback) { if (shortcut_feedback && is_inside_tree()) {
if (shortcut_feedback_timer == nullptr) { if (shortcut_feedback_timer == nullptr) {
shortcut_feedback_timer = memnew(Timer); shortcut_feedback_timer = memnew(Timer);
shortcut_feedback_timer->set_one_shot(true); shortcut_feedback_timer->set_one_shot(true);