Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Caks2016-08-19 11:21:42 +0000
committerChristoph Caks2016-08-19 11:21:42 +0000
commit906de76638f86a6b3a6a16dc6c11a49c18ebe631 (patch)
tree834ad161385ec0ee549ba9cd3311d5cf4f711f04
parent54a0eade07ab460b9e27a703065f3b22dffd31da (diff)
downloadorg.eclipse.efxclipse-906de76638f86a6b3a6a16dc6c11a49c18ebe631.tar.gz
org.eclipse.efxclipse-906de76638f86a6b3a6a16dc6c11a49c18ebe631.tar.xz
org.eclipse.efxclipse-906de76638f86a6b3a6a16dc6c11a49c18ebe631.zip
FixListBinding: re-added WeakListener and fixed it
-rw-r--r--bundles/runtime/org.eclipse.fx.core.tests/src/org/eclipse/fx/core/property/FXBindingsTest.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/internal/FixListBinding.java6
2 files changed, 6 insertions, 2 deletions
diff --git a/bundles/runtime/org.eclipse.fx.core.tests/src/org/eclipse/fx/core/property/FXBindingsTest.java b/bundles/runtime/org.eclipse.fx.core.tests/src/org/eclipse/fx/core/property/FXBindingsTest.java
index 27d6f5043..aeb167ad5 100644
--- a/bundles/runtime/org.eclipse.fx.core.tests/src/org/eclipse/fx/core/property/FXBindingsTest.java
+++ b/bundles/runtime/org.eclipse.fx.core.tests/src/org/eclipse/fx/core/property/FXBindingsTest.java
@@ -350,6 +350,8 @@ public class FXBindingsTest {
l0.add("!!!");
+ System.gc();
+
Assert.assertArrayEquals(new String[] {
"yay",
"!!!",
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/internal/FixListBinding.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/internal/FixListBinding.java
index 7a3891e9f..dfcfe39aa 100644
--- a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/internal/FixListBinding.java
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/bindings/internal/FixListBinding.java
@@ -8,6 +8,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ListChangeListener.Change;
import javafx.collections.ObservableList;
+import javafx.collections.WeakListChangeListener;
@SuppressWarnings("javadoc")
@@ -16,10 +17,11 @@ public class FixListBinding<A> extends ListBinding<A> {
private ObservableList<A> fixed;
private ListChangeListener<A> changeListener = this::onSourceChange;
+ private WeakListChangeListener<A> weakChangeListener = new WeakListChangeListener<>(this.changeListener);
public FixListBinding(ObservableList<A> source) {
this.source = source;
- this.source.addListener(this.changeListener);
+ this.source.addListener(this.weakChangeListener);
}
private void onSourceChange(Change<? extends A> change) {
@@ -142,7 +144,7 @@ public class FixListBinding<A> extends ListBinding<A> {
@Override
public void dispose() {
- this.source.removeListener(this.changeListener);
+ this.source.removeListener(this.weakChangeListener);
super.dispose();
}

Back to the top