diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-11 08:33:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-11 08:33:23 +0100 |
commit | 95eab06471477237797634537afc1106607ece4f (patch) | |
tree | 4c559f265fa79825ebdc5109787ff1c47a60b063 /scene | |
parent | 61e89dcd4aa57853e60402839459de77143462ce (diff) | |
parent | c29b8cf751d9c30803826d863e17ebfeb464bd1c (diff) |
Merge pull request #34239 from timothyqiu/theme-clear-32702
Fixes crash when using Theme::clear
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/theme.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index c897365b21..bf9079c9f4 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -720,7 +720,10 @@ void Theme::clear() { while ((K = icon_map.next(K))) { const StringName *L = NULL; while ((L = icon_map[*K].next(L))) { - icon_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed"); + Ref<Texture> icon = icon_map[*K][*L]; + if (icon.is_valid()) { + icon->disconnect("changed", this, "_emit_theme_changed"); + } } } } @@ -730,7 +733,10 @@ void Theme::clear() { while ((K = style_map.next(K))) { const StringName *L = NULL; while ((L = style_map[*K].next(L))) { - style_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed"); + Ref<StyleBox> style = style_map[*K][*L]; + if (style.is_valid()) { + style->disconnect("changed", this, "_emit_theme_changed"); + } } } } @@ -740,7 +746,10 @@ void Theme::clear() { while ((K = font_map.next(K))) { const StringName *L = NULL; while ((L = font_map[*K].next(L))) { - font_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed"); + Ref<Font> font = font_map[*K][*L]; + if (font.is_valid()) { + font->disconnect("changed", this, "_emit_theme_changed"); + } } } } |