1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 02:58:00 +01:00

Fixes a problem that prevented to remove listeners

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2207 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-01-15 13:05:44 +00:00 committed by gdombiak
parent d25d36448e
commit 3abb8b109c

View file

@ -143,7 +143,12 @@ class PacketWriter {
*/
public void removePacketListener(PacketListener packetListener) {
synchronized (listeners) {
listeners.remove(packetListener);
for (int i=0; i<listeners.size(); i++) {
ListenerWrapper wrapper = (ListenerWrapper)listeners.get(i);
if (wrapper != null && wrapper.packetListener.equals(packetListener)) {
listeners.set(i, null);
}
}
}
}
@ -249,6 +254,16 @@ class PacketWriter {
}
}
if (sentPacket != null) {
// Clean up null entries in the listeners list
synchronized (listeners) {
if (listeners.size() > 0) {
for (int i=listeners.size()-1; i>=0; i--) {
if (listeners.get(i) == null) {
listeners.remove(i);
}
}
}
}
// Notify the listeners of the new sent packet
int size = listeners.size();
for (int i=0; i<size; i++) {