Unify and streamline connecting to Resource changes

This commit is contained in:
kobewi
2023-07-03 21:29:37 +02:00
parent 2c55214068
commit de4a3fa151
98 changed files with 341 additions and 434 deletions
+2 -3
View File
@@ -30,7 +30,6 @@
#include "texture_button.h"
#include "core/core_string_names.h"
#include "core/typedefs.h"
#include <stdlib.h>
@@ -353,12 +352,12 @@ void TextureButton::_set_texture(Ref<Texture2D> *p_destination, const Ref<Textur
return;
}
if (destination.is_valid()) {
destination->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureButton::_texture_changed));
destination->disconnect_changed(callable_mp(this, &TextureButton::_texture_changed));
}
destination = p_texture;
if (destination.is_valid()) {
// Pass `CONNECT_REFERENCE_COUNTED` to avoid early disconnect in case the same texture is assigned to different "slots".
destination->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureButton::_texture_changed), CONNECT_REFERENCE_COUNTED);
destination->connect_changed(callable_mp(this, &TextureButton::_texture_changed), CONNECT_REFERENCE_COUNTED);
}
_texture_changed();
}