From 0648cc65b2c9bd8a48f3da74ea2c17898cd2b425 Mon Sep 17 00:00:00 2001 From: Ninni Pipping Date: Wed, 17 May 2023 16:05:11 +0200 Subject: [PATCH] Make `TouchScreenButton` connections reference counted Prevents errors when assigning the same texture to both slots --- scene/2d/touch_screen_button.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 4c8c4f1e16d3..7da2fc3cb36e 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -42,7 +42,7 @@ void TouchScreenButton::set_texture_normal(const Ref &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 &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(); }