From 86107ceec6c6902215b52d43c09cf0bc02f5e99c Mon Sep 17 00:00:00 2001 From: Valentin Martinet Date: Wed, 13 Jan 2010 12:26:16 +0000 Subject: [PATCH] Fix a ConcurrentModificationException when closing multiple chat tabs in one click. --- .../impl/gui/main/chat/ChatWindowManager.java | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java index c6aceb82e..03f3008f7 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java @@ -250,30 +250,32 @@ void closeWindow(ChatWindow chatWindow) synchronized (syncChat) { ChatPanel activePanel = null; - - for (ChatPanel chatPanel : chatPanels) + synchronized (chatPanels) { - if (chatPanel.getChatSession() instanceof - AdHocConferenceChatSession) - { - AdHocConferenceChatSession adHocSession - = (AdHocConferenceChatSession) chatPanel - .getChatSession(); - - GuiActivator.getUIService().getConferenceChatManager() - .leaveChatRoom( - (AdHocChatRoomWrapper) adHocSession.getDescriptor()); - } - - if (!chatPanel.isWriteAreaEmpty() - || chatPanel.containsActiveFileTransfers() - || System.currentTimeMillis() - chatWindow - .getLastIncomingMsgTimestamp(chatPanel) < 2 * 1000) - { - activePanel = chatPanel; - } + for (ChatPanel chatPanel : chatPanels) + { + if (chatPanel.getChatSession() instanceof + AdHocConferenceChatSession) + { + AdHocConferenceChatSession adHocSession + = (AdHocConferenceChatSession) chatPanel + .getChatSession(); + + GuiActivator.getUIService().getConferenceChatManager() + .leaveChatRoom((AdHocChatRoomWrapper) + adHocSession.getDescriptor()); + } + + if (!chatPanel.isWriteAreaEmpty() + || chatPanel.containsActiveFileTransfers() + || System.currentTimeMillis() - chatWindow + .getLastIncomingMsgTimestamp(chatPanel) < 2 * 1000) + { + activePanel = chatPanel; + } + } } - + if (activePanel == null) { this.disposeChatWindow(chatWindow);