Fixes a memory leak of ChatWindow instances opened in response to receiving messages.

cusax-fix
Lyubomir Marinov 18 years ago
parent 0de7e6c32c
commit d65088550e

@ -51,7 +51,7 @@ public class ChatWindow
{
private Logger logger = Logger.getLogger(ChatWindow.class.getName());
private MenusPanel menusPanel;
private final MenusPanel menusPanel;
private MainFrame mainFrame;
@ -149,6 +149,7 @@ public void dispose()
try
{
GuiActivator.getUIService().removePluginComponentListener(this);
menusPanel.dispose();
}
finally
{

@ -21,15 +21,16 @@
* window.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class MenusPanel
extends JPanel
{
private MessageWindowMenuBar menuBar;
private final MessageWindowMenuBar menuBar;
private MainToolBar mainToolBar;
private final MainToolBar mainToolBar;
private ChatWindow parentWindow;
private final ChatWindow parentWindow;
/**
* Creates an instance and constructs the <tt>MenusPanel</tt>.
@ -59,6 +60,17 @@ public MenusPanel(ChatWindow parentWindow)
this.add(mainToolBar, BorderLayout.CENTER);
}
/**
* Runs clean-up for associated resources which need explicit disposal (e.g.
* listeners keeping this instance alive because they were added to the
* model which operationally outlives this instance).
*/
public void dispose()
{
mainToolBar.dispose();
menuBar.dispose();
}
/**
* Adds a new toolbar to this <tt>MenusPanel</tt>.
*

@ -24,18 +24,14 @@
* The <tt>HelpMenu</tt> is a menu in the main application menu bar.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class HelpMenu
extends SIPCommMenu
implements ActionListener,
PluginComponentListener
{
private Logger logger = Logger.getLogger(HelpMenu.class.getName());
private I18NString aboutString = Messages.getI18NString("about");
private ChatWindow chatWindow;
private final Logger logger = Logger.getLogger(HelpMenu.class.getName());
/**
* Creates an instance of <tt>HelpMenu</tt>.
@ -45,8 +41,6 @@ public HelpMenu(ChatWindow chatWindow) {
super(Messages.getI18NString("help").getText());
this.chatWindow = chatWindow;
this.setForeground(new Color(
GuiActivator.getResources().getColor("chatMenuForeground")));
@ -55,6 +49,22 @@ public HelpMenu(ChatWindow chatWindow) {
this.initPluginComponents();
}
/**
* Runs clean-up for associated resources which need explicit disposal (e.g.
* listeners keeping this instance alive because they were added to the
* model which operationally outlives this instance).
*/
public void dispose()
{
GuiActivator.getUIService().removePluginComponentListener(this);
/*
* Let go of all Components contributed by PluginComponents because the
* latter will still live in the contribution store.
*/
removeAll();
}
/**
* Initialize plugin components already registered for this container.
*/

@ -26,20 +26,21 @@
* all menus are added.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class MessageWindowMenuBar
extends JMenuBar
implements PluginComponentListener
{
private Logger logger = Logger.getLogger(MessageWindowMenuBar.class);
private final Logger logger = Logger.getLogger(MessageWindowMenuBar.class);
private FileMenu fileMenu;
private EditMenu editMenu;
private HelpMenu helpMenu;
private final HelpMenu helpMenu;
private ChatWindow parentWindow;
private final ChatWindow parentWindow;
/**
* Creates an instance of <tt>MessageWindowMenuBar</tt>.
@ -62,6 +63,17 @@ public MessageWindowMenuBar(ChatWindow parentWindow)
this.initPluginComponents();
}
/**
* Runs clean-up for associated resources which need explicit disposal (e.g.
* listeners keeping this instance alive because they were added to the
* model which operationally outlives this instance).
*/
public void dispose()
{
GuiActivator.getUIService().removePluginComponentListener(this);
helpMenu.dispose();
}
/**
* Initializes the menu bar, by adding all contained menus.
*/

@ -37,6 +37,7 @@
* rollover behaviour to differentiates them from normal buttons.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class MainToolBar
extends SIPCommToolBar
@ -262,6 +263,16 @@ public void chatChanged(ChatPanel panel)
});
}
/**
* Runs clean-up for associated resources which need explicit disposal (e.g.
* listeners keeping this instance alive because they were added to the
* model which operationally outlives this instance).
*/
public void dispose()
{
GuiActivator.getUIService().removePluginComponentListener(this);
}
/**
* Handles the <tt>ActionEvent</tt>, when one of the toolbar buttons is
* clicked.

Loading…
Cancel
Save