From 9de8c209f1ae88a807ec45b45e61923051986594 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 23 Oct 2019 16:08:12 +0200 Subject: [PATCH] texture_added and _texture_added will only be called if an addition actually occurs. (Refcount increases won't count as addition). --- texture_merger.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/texture_merger.cpp b/texture_merger.cpp index 457ce3f..13c72c6 100644 --- a/texture_merger.cpp +++ b/texture_merger.cpp @@ -78,7 +78,13 @@ void TextureMerger::set_textures(const Vector &textures) { Ref tex = _textures.get(i); if (tex.is_valid() && !_packer->contains_texture(tex)) { - _packer->add_texture(tex); + Ref tex = _packer->add_texture(tex); + + if (has_method("_texture_added")) + call("_texture_added", tex); + + emit_signal("texture_added", tex); + texture_added = true; } } @@ -92,12 +98,16 @@ Ref TextureMerger::add_texture(Ref texture) { _textures.push_back(texture); + bool contains = _packer->contains_texture(texture); + Ref tex = _packer->add_texture(texture); - if (has_method("_texture_added")) - call("_texture_added", tex); + if (!contains) { + if (has_method("_texture_added")) + call("_texture_added", tex); - emit_signal("texture_added", tex); + emit_signal("texture_added", tex); + } return tex; }