Fixes releasing plugin components when the strong value is referring the key and cannot be released.

cusax-fix
Damian Minkov 13 years ago
parent 389e6ea966
commit ad90be2ffb

@ -6,6 +6,7 @@
*/
package net.java.sip.communicator.service.gui;
import java.lang.ref.*;
import java.util.*;
/**
@ -41,8 +42,8 @@ public abstract class PluginComponentFactory
* Weak hash map holding plugins if the parent (container) is garbage
* collected free and the plugin instance that corresponds it.
*/
private WeakHashMap<Object,PluginComponent> pluginInstances =
new WeakHashMap<Object, PluginComponent>();
private WeakHashMap<Object,WeakReference<PluginComponent>> pluginInstances =
new WeakHashMap<Object, WeakReference<PluginComponent>>();
/**
* Creates a default factory for a <tt>container</tt>.
@ -133,16 +134,17 @@ public boolean isNativeComponent()
*
* @return the component that should be added.
*/
@SuppressWarnings("unchecked")
public PluginComponent getPluginComponentInstance(Object parent)
{
PluginComponent p = pluginInstances.get(parent);
WeakReference<PluginComponent> p = pluginInstances.get(parent);
if(p == null)
{
p = getPluginInstance();
p = new WeakReference(getPluginInstance());
pluginInstances.put(parent, p);
}
return p;
return p.get();
}
/**

Loading…
Cancel
Save