mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-27 14:47:59 +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:
parent
d25d36448e
commit
3abb8b109c
1 changed files with 16 additions and 1 deletions
|
@ -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++) {
|
||||
|
|
Loading…
Reference in a new issue