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

View File

@@ -31,7 +31,6 @@
#include "texture_progress_bar.h"
#include "core/config/engine.h"
#include "core/core_string_names.h"
#include "scene/resources/atlas_texture.h"
void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
@@ -162,12 +161,12 @@ void TextureProgressBar::_set_texture(Ref<Texture2D> *p_destination, const Ref<T
return;
}
if (destination.is_valid()) {
destination->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureProgressBar::_texture_changed));
destination->disconnect_changed(callable_mp(this, &TextureProgressBar::_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, &TextureProgressBar::_texture_changed), CONNECT_REFERENCE_COUNTED);
destination->connect_changed(callable_mp(this, &TextureProgressBar::_texture_changed), CONNECT_REFERENCE_COUNTED);
}
_texture_changed();
}