Skip to content

Commit

Permalink
Remove listeners from Nodes when value was an IPropertyPitProvider an…
Browse files Browse the repository at this point in the history
…d it was changed.

Issue was that changing the IPropertyPitProvider on an IProperty kept the old listeners.
  • Loading branch information
jboesl committed Nov 7, 2018
1 parent c656426 commit e753ed8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@

import de.adito.propertly.core.common.PropertlyUtility;
import de.adito.propertly.core.common.path.PropertyPath;
import de.adito.propertly.core.spi.IProperty;
import de.adito.propertly.core.spi.IPropertyDescription;
import de.adito.propertly.core.spi.IPropertyPitEventListener;
import de.adito.propertly.core.spi.IPropertyPitProvider;
import de.adito.propertly.core.spi.*;
import de.adito.util.weak.MixedReferences;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.*;

import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;

/**
* Abstract class for INode implementations.
*
* @author PaL
* Date: 09.02.13
* Time: 19:36
* Date: 09.02.13
* Time: 19:36
*/
public abstract class AbstractNode implements INode
{
Expand Down Expand Up @@ -83,6 +78,11 @@ public void remove()
listeners = null;
}

protected void clearListeners()
{
listeners.clear();
}

@Override
public void addWeakListener(@NotNull IPropertyPitEventListener pListener)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public Object setValue(@Nullable Object pValue, @NotNull Set<Object> pAttributes
List<Runnable> onFinish = new ArrayList<>();
fireValueWillBeChange(oldValue, pValue, onFinish::add, pAttributes);
delegate.setValue(pValue, pAttributes);
clearListeners();
_alignToDelegate();
Object newValue = getValueInternal();
fireValueChange(oldValue, newValue, pAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public Object setValue(Object pValue, @NotNull Set<Object> pAttributes)
}
HierarchyHelper.setNode((IPropertyPitProvider) oldValue, null);
}
clearListeners();
if (pppProvider != null) {
IPropertyPitProvider pppCopy = PropertlyUtility.create(pppProvider);
value = pppCopy;
Expand Down

0 comments on commit e753ed8

Please sign in to comment.