mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-1177, possibly found the memory leak in BuzzRoomDecorator
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12483 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
8148e7cf50
commit
fb64898298
@ -362,7 +362,7 @@ public class SparkTabbedPane extends JPanel {
|
||||
final Iterator<SparkTabbedPaneListener> list = ModelUtil.reverseListIterator(listeners
|
||||
.listIterator());
|
||||
while (list.hasNext()) {
|
||||
((SparkTabbedPaneListener) list.next()).allTabsRemoved();
|
||||
list.next().allTabsRemoved();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -260,11 +260,11 @@ public class ChatFrame extends JFrame implements WindowFocusListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listeners who want to get informed
|
||||
* removes the Window to Front Listener for specified {@link ChatRoom}
|
||||
* @param chatRoom
|
||||
*/
|
||||
public void removeWindowToFronListener(ChatRoom chatRoom) {
|
||||
_windowToFrontListeners .remove(chatRoom);
|
||||
public void removeWindowToFrontListener(ChatRoom chatRoom) {
|
||||
_windowToFrontListeners.remove(chatRoom);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +273,7 @@ public class ChatFrame extends JFrame implements WindowFocusListener {
|
||||
* @param chatRoom
|
||||
*/
|
||||
public void addWindowToFronListener(ChatRoom chatRoom) {
|
||||
_windowToFrontListeners .add(chatRoom);
|
||||
_windowToFrontListeners.add(chatRoom);
|
||||
fireWindowOnTopListeners(chatFrame.isAlwaysOnTop());
|
||||
}
|
||||
|
||||
|
||||
@ -50,13 +50,11 @@ public class ChatInputEditor extends ChatArea implements DocumentListener {
|
||||
private KeyStroke undoKeyStroke;
|
||||
private KeyStroke ctrlbackspaceKeyStroke;
|
||||
private KeyStroke escapeKeyStroke;
|
||||
private ChatInputEditor _chatinputeditor;
|
||||
|
||||
/**
|
||||
* Creates a new Default ChatSendField.
|
||||
*/
|
||||
public ChatInputEditor() {
|
||||
_chatinputeditor = this;
|
||||
undoManager = new UndoManager();
|
||||
|
||||
this.setDragEnabled(true);
|
||||
@ -88,7 +86,7 @@ public class ChatInputEditor extends ChatArea implements DocumentListener {
|
||||
|
||||
// We have Text selected, remove it
|
||||
if (getSelectedText() != null && getSelectedText().length() > 0) {
|
||||
_chatinputeditor.removeWordInBetween(getSelectionStart(),
|
||||
ChatInputEditor.this.removeWordInBetween(getSelectionStart(),
|
||||
getSelectionEnd());
|
||||
|
||||
// We are somewhere in betwee 0 and str.length
|
||||
@ -108,7 +106,7 @@ public class ChatInputEditor extends ChatArea implements DocumentListener {
|
||||
}
|
||||
lastSpace++;
|
||||
}
|
||||
_chatinputeditor.removeWordInBetween(lastSpace,
|
||||
ChatInputEditor.this.removeWordInBetween(lastSpace,
|
||||
getCaretPosition());
|
||||
|
||||
if (lastSpace <= getText().length()) {
|
||||
@ -126,10 +124,10 @@ public class ChatInputEditor extends ChatArea implements DocumentListener {
|
||||
untilhere--;
|
||||
}
|
||||
untilhere++;
|
||||
_chatinputeditor.removeLastWord(getText().substring(
|
||||
ChatInputEditor.this.removeLastWord(getText().substring(
|
||||
untilhere));
|
||||
} else {
|
||||
_chatinputeditor.removeLastWord(getText());
|
||||
ChatInputEditor.this.removeLastWord(getText());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -72,6 +72,7 @@ import org.jivesoftware.spark.ChatAreaSendField;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.component.BackgroundPanel;
|
||||
import org.jivesoftware.spark.component.RolloverButton;
|
||||
import org.jivesoftware.spark.component.tabbedPane.SparkTab;
|
||||
import org.jivesoftware.spark.plugin.ContextMenuListener;
|
||||
import org.jivesoftware.spark.ui.rooms.GroupChatRoom;
|
||||
import org.jivesoftware.spark.util.GraphicUtils;
|
||||
@ -790,6 +791,7 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener
|
||||
getTranscriptWindow().removeContextMenuListener(this);
|
||||
getTranscriptWindow().removeMouseListener(transcriptWindowMouseListener);
|
||||
getChatInputEditor().removeKeyListener(chatEditorKeyListener);
|
||||
this.removeAll();
|
||||
|
||||
textScroller.getViewport().remove(transcriptWindow);
|
||||
|
||||
@ -808,6 +810,8 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener
|
||||
getChatInputEditor().getActionMap().remove("closeTheRoom");
|
||||
chatAreaButton.getButton().removeActionListener(this);
|
||||
bottomPanel.remove(chatAreaButton);
|
||||
_chatFrame.removeWindowToFrontListener(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -109,6 +109,7 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
private ChatRoomButton infoButton;
|
||||
|
||||
private ChatRoomButton addToRosterButton;
|
||||
private VCardPanel vcardPanel;
|
||||
|
||||
/**
|
||||
* Constructs a 1-to-1 ChatRoom.
|
||||
@ -228,6 +229,11 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
typingTimerTask = null;
|
||||
}
|
||||
active = false;
|
||||
this.remove(vcardPanel);
|
||||
vcardPanel.removeAll();
|
||||
vcardPanel = null;
|
||||
|
||||
this.removeAll();
|
||||
}
|
||||
|
||||
public void sendMessage() {
|
||||
@ -635,7 +641,7 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
|
||||
private void loadHistory() {
|
||||
// Add VCard Panel
|
||||
final VCardPanel vcardPanel = new VCardPanel(participantJID);
|
||||
vcardPanel = new VCardPanel(participantJID);
|
||||
getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 2), 0, 0));
|
||||
|
||||
|
||||
@ -682,7 +688,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
}
|
||||
if ( 0 < chatTranscript.getMessages().size() ) { // Check if we have history mesages
|
||||
getTranscriptWindow().insertHorizontalLine();
|
||||
}
|
||||
}
|
||||
chatTranscript.release();
|
||||
}
|
||||
|
||||
private boolean isOnline() {
|
||||
|
||||
@ -21,7 +21,6 @@ package org.jivesoftware.sparkimpl.plugin.alerts;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
@ -46,34 +45,21 @@ public class BuzzRoomDecorator implements ActionListener {
|
||||
|
||||
private ChatRoom chatRoom;
|
||||
private RolloverButton buzzButton;
|
||||
private static ArrayList<BuzzRoomDecorator> objects = new ArrayList<BuzzRoomDecorator>();
|
||||
private String jid;
|
||||
|
||||
|
||||
public BuzzRoomDecorator(ChatRoom chatRoom) {
|
||||
this.chatRoom = chatRoom;
|
||||
jid = ((ChatRoomImpl)chatRoom).getParticipantJID();
|
||||
boolean added = false;
|
||||
|
||||
for(BuzzRoomDecorator buzz : objects)
|
||||
{
|
||||
if(buzz.jid == ((ChatRoomImpl)chatRoom).getParticipantJID())
|
||||
{
|
||||
addBuzzButton(buzz);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!added)
|
||||
{
|
||||
buzzButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.BUZZ_IMAGE));
|
||||
buzzButton.setToolTipText(Res.getString("message.buzz.alert.notification"));
|
||||
buzzButton.addActionListener(this);
|
||||
|
||||
final JLabel dividerLabel = new JLabel(SparkRes.getImageIcon("DIVIDER_IMAGE"));
|
||||
chatRoom.getEditorBar().add(dividerLabel);
|
||||
chatRoom.getEditorBar().add(buzzButton);
|
||||
objects.add(this);
|
||||
}
|
||||
this.chatRoom = chatRoom;
|
||||
|
||||
buzzButton = new RolloverButton(
|
||||
SparkRes.getImageIcon(SparkRes.BUZZ_IMAGE));
|
||||
buzzButton.setToolTipText(Res
|
||||
.getString("message.buzz.alert.notification"));
|
||||
buzzButton.addActionListener(this);
|
||||
|
||||
final JLabel dividerLabel = new JLabel(
|
||||
SparkRes.getImageIcon("DIVIDER_IMAGE"));
|
||||
chatRoom.getEditorBar().add(dividerLabel);
|
||||
chatRoom.getEditorBar().add(buzzButton);
|
||||
}
|
||||
|
||||
public void addBuzzButton(BuzzRoomDecorator buzzer)
|
||||
|
||||
@ -88,4 +88,11 @@ public class ChatTranscript {
|
||||
return searchResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the Message History if its not needed anymore
|
||||
*/
|
||||
public void release() {
|
||||
messages.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +262,8 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
||||
transcript.addHistoryMessage(history);
|
||||
}
|
||||
|
||||
ChatTranscripts.appendToTranscript(jid, transcript);
|
||||
ChatTranscripts.appendToTranscript(jid, transcript);
|
||||
lastMessage.remove(room);
|
||||
}
|
||||
|
||||
public void chatRoomActivated(ChatRoom room) {
|
||||
@ -329,12 +330,6 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
||||
GraphicUtils.centerWindowOnScreen(frame);
|
||||
frame.setVisible(true);
|
||||
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
window.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
window.setEditable(false);
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
@ -445,6 +440,7 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
||||
|
||||
window.setText(builder.toString());
|
||||
builder.replace(0, builder.length(), "");
|
||||
transcript.release();
|
||||
}
|
||||
};
|
||||
|
||||
@ -477,8 +473,23 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
||||
});
|
||||
|
||||
TaskEngine.getInstance().schedule(transcriptTask, 10);
|
||||
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
window.setText("");
|
||||
}
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
frame.removeWindowListener(this);
|
||||
frame.dispose();
|
||||
transcriptTask.cancel();
|
||||
topPanel.remove(vacardPanel);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
transcriptLoader.start();
|
||||
}
|
||||
@ -565,6 +576,8 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
|
||||
chatHistoryButton.removeActionListener(this);
|
||||
}
|
||||
chatRoom.removeClosingListener(this);
|
||||
chatRoom = null;
|
||||
chatHistoryButton = null;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
Reference in New Issue
Block a user