summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-08-25 00:04:17 +0200
committerGitHub <noreply@github.com>2022-08-25 00:04:17 +0200
commitefedef8eb1ff931a046240091e4841cb886569ca (patch)
tree6b2014be57f82b442b6f2fdcacdc9eee2cb231ad /scene
parentbb6d7713972b1e73e651396953123084a90dc86d (diff)
parentbb5fa91a6be1cec688267b3ff43bb7a4d8cbf951 (diff)
Merge pull request #64837 from YuriSizov/control-disconnect-from-everything-and-free-yourself
Disconnect Control from theme resources to avoid issues on destruction
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/control.cpp21
-rw-r--r--scene/gui/control.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 66cb41ee65..03fcef17f5 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -3622,3 +3622,24 @@ void Control::_bind_methods() {
GDVIRTUAL_BIND(_gui_input, "event");
}
+
+Control::~Control() {
+ // Resources need to be disconnected.
+ for (KeyValue<StringName, Ref<Texture2D>> &E : data.icon_override) {
+ E.value->disconnect("changed", callable_mp(this, &Control::_theme_property_override_changed));
+ }
+ for (KeyValue<StringName, Ref<StyleBox>> &E : data.style_override) {
+ E.value->disconnect("changed", callable_mp(this, &Control::_theme_property_override_changed));
+ }
+ for (KeyValue<StringName, Ref<Font>> &E : data.font_override) {
+ E.value->disconnect("changed", callable_mp(this, &Control::_theme_property_override_changed));
+ }
+
+ // Then override maps can be simply cleared.
+ data.icon_override.clear();
+ data.style_override.clear();
+ data.font_override.clear();
+ data.font_size_override.clear();
+ data.color_override.clear();
+ data.constant_override.clear();
+}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index d7e120260c..c69067f82f 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -610,6 +610,7 @@ public:
virtual Control *make_custom_tooltip(const String &p_text) const;
Control() {}
+ ~Control();
};
VARIANT_ENUM_CAST(Control::FocusMode);