Make TouchScreenButton connections reference counted

Prevents errors when assigning the same texture to both slots

(cherry picked from commit 0648cc65b2)
This commit is contained in:
Ninni Pipping 2023-05-18 19:22:23 +02:00 committed by Yuri Sizov
parent 238b8357a3
commit 589306a9d8

View File

@ -42,7 +42,7 @@ void TouchScreenButton::set_texture_normal(const Ref<Texture2D> &p_texture) {
}
texture_normal = p_texture;
if (texture_normal.is_valid()) {
texture_normal->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw));
texture_normal->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw), CONNECT_REFERENCE_COUNTED);
}
queue_redraw();
}
@ -60,7 +60,7 @@ void TouchScreenButton::set_texture_pressed(const Ref<Texture2D> &p_texture_pres
}
texture_pressed = p_texture_pressed;
if (texture_pressed.is_valid()) {
texture_pressed->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw));
texture_pressed->connect(SceneStringNames::get_singleton()->changed, callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw), CONNECT_REFERENCE_COUNTED);
}
queue_redraw();
}