Unify and streamline connecting to Resource changes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user