Fixes memory leak on macosx.

cusax-fix
Damian Minkov 14 years ago
parent 3b2b980504
commit efce3299dd

@ -8,11 +8,14 @@
import java.awt.*;
import java.awt.image.*;
import java.beans.*;
import java.lang.reflect.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.skin.*;
import net.java.sip.communicator.util.swing.*;
@ -190,4 +193,38 @@ public void loadSkin()
}
}
}
/**
* Cleanup.
*/
public void dispose()
{
if(OSUtils.IS_MAC)
{
// Apple introduced a memory leak in JViewport class -
// they add a PropertyChangeListeners to the CToolkit
try
{
PropertyChangeListener[] pcl =Toolkit.getDefaultToolkit()
.getPropertyChangeListeners("apple.awt.contentScaleFactor");
for(PropertyChangeListener pc : pcl)
{
// find the reference to the object created the listener
Field f = pc.getClass().getDeclaredField("this$0");
f.setAccessible(true);
// if we are the parent cleanup
if(f.get(pc).equals(this.getViewport()))
{
Toolkit.getDefaultToolkit()
.removePropertyChangeListener(
"apple.awt.contentScaleFactor", pc);
break;
}
}
}
catch(Throwable t)
{}
}
}
}

@ -319,4 +319,12 @@ public void serviceChanged(ServiceEvent event)
break;
}
}
/**
* Implements the <tt>SIPCommDialog</tt> close method.
*/
protected void close(boolean isEscaped)
{
summaryPage.dispose();
}
}

@ -324,6 +324,7 @@ public void dispose()
{
writeMessagePanel.dispose();
chatSession.dispose();
conversationPanel.dispose();
}
/**

@ -365,6 +365,8 @@ public void dispose()
stoppedTypingTimer.removeActionListener(this);
if (typingState != OperationSetTypingNotifications.STATE_STOPPED)
stopTypingTimer();
scrollPane.dispose();
}
/**

@ -747,6 +747,9 @@ else if(historyMenu.isPopupMenuVisible())
GuiActivator.getUIService().getHistoryWindowManager()
.removeHistoryWindowForContact(historyContact);
datesPanel.dispose();
chatConvPanel.dispose();
this.dispose();
}
}

@ -56,6 +56,8 @@ public class ChatRoomListDialog
*/
private static ChatRoomListDialog chatRoomListDialog;
private ChatRoomListUI chatRoomsListUI;
/**
* Shows a <code>ChatRoomListDialog</code> creating it first if necessary.
* The shown instance is shared in order to prevent displaying multiple
@ -110,7 +112,7 @@ public ChatRoomListDialog(MainFrame parentWindow)
*/
private void init()
{
ChatRoomListUI chatRoomsListUI = new ChatRoomListUI(this);
chatRoomsListUI = new ChatRoomListUI(this);
JButton createChatRoomButton = new JButton(
GuiActivator.getResources()
@ -167,6 +169,7 @@ else if (buttonName.equals(JOIN_CHAT_ROOM))
@Override
protected void close(boolean isEscaped)
{
chatRoomsListUI.dispose();
this.dispose();
}
}

@ -502,6 +502,7 @@ else if(sourceButton.equals(cancelButton))
@Override
protected void close(boolean isEscaped)
{
chatRoomsTableUI.dispose();
chatRoomTableDialog = null;
dispose();

@ -408,49 +408,56 @@ private void init()
if(infoOpSet != null)
{
details = infoOpSet.getAllDetailsForContact(contact);
while(details.hasNext())
try
{
GenericDetail d = details.next();
if(d instanceof PhoneNumberDetail &&
!(d instanceof PagerDetail) &&
!(d instanceof FaxDetail))
details = infoOpSet.getAllDetailsForContact(contact);
while(details.hasNext())
{
PhoneNumberDetail pnd = (PhoneNumberDetail)d;
if(pnd.getNumber() != null &&
pnd.getNumber().length() > 0)
GenericDetail d = details.next();
if(d instanceof PhoneNumberDetail &&
!(d instanceof PagerDetail) &&
!(d instanceof FaxDetail))
{
String localizedType = null;
if(d instanceof WorkPhoneDetail)
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.WORK_PHONE");
}
else if(d instanceof MobilePhoneDetail)
PhoneNumberDetail pnd = (PhoneNumberDetail)d;
if(pnd.getNumber() != null &&
pnd.getNumber().length() > 0)
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.MOBILE_PHONE");
String localizedType;
if(d instanceof WorkPhoneDetail)
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.WORK_PHONE");
}
else if(d instanceof MobilePhoneDetail)
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.MOBILE_PHONE");
}
else
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.PHONE");
}
phones.add(pnd.getNumber()
+ " (" + localizedType + ")");
hasPhones = true;
}
else
{
localizedType =
GuiActivator.getResources().
getI18NString(
"service.gui.PHONE");
}
phones.add(pnd.getNumber()
+ " (" + localizedType + ")");
hasPhones = true;
}
}
}
catch(Throwable t)
{
logger.error("Error obtaining server stored contact info");
}
}
// add all the contacts that support telephony to the call menu

Loading…
Cancel
Save