diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/DataChangeLayerIntegrationTest.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/DataChangeLayerIntegrationTest.java index d8084163..48651c57 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/DataChangeLayerIntegrationTest.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/DataChangeLayerIntegrationTest.java @@ -135,6 +135,10 @@ public boolean matches(Person item) { assertFalse(this.dataChangeLayer.getDataChanges().isEmpty()); assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty"); + // short sleep to avoid handling the next step in the previous + // processing + Thread.sleep(100); + countDownLatch = new CountDownLatch(1); this.listenerFixture.setCountDownLatch(countDownLatch); diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/RowStructuralDataChangeLayerIntegrationTest.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/RowStructuralDataChangeLayerIntegrationTest.java index 43c89be3..16211b9a 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/RowStructuralDataChangeLayerIntegrationTest.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/RowStructuralDataChangeLayerIntegrationTest.java @@ -428,6 +428,10 @@ public void shouldKeepChangeOnFilter() throws InterruptedException { assertFalse(this.dataChangeLayer.getDataChanges().isEmpty()); assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty"); + // short sleep to avoid handling the next step in the previous + // processing + Thread.sleep(100); + countDownLatch = new CountDownLatch(1); this.listenerFixture.setCountDownLatch(countDownLatch); this.filterList.setMatcher(null); diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java index 54bf6487..f3e44ecf 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2023 Original authors and others. + * Copyright (c) 2012, 2024 Original authors and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -58,7 +58,7 @@ public class GlazedListsEventLayer private EventList eventList; private boolean testMode = false; private boolean structuralChangeEventsToProcess = false; - private boolean eventsToProcess = false; + private AtomicBoolean eventsToProcess = new AtomicBoolean(false); private AtomicBoolean terminated = new AtomicBoolean(false); private boolean active = true; @@ -81,7 +81,7 @@ public GlazedListsEventLayer(IUniqueIndexLayer underlyingLayer, EventList eve */ protected Runnable getEventNotifier() { return () -> { - if (GlazedListsEventLayer.this.eventsToProcess && GlazedListsEventLayer.this.active) { + if (GlazedListsEventLayer.this.active && GlazedListsEventLayer.this.eventsToProcess.compareAndSet(true, false)) { ILayerEvent layerEvent; if (GlazedListsEventLayer.this.structuralChangeEventsToProcess) { layerEvent = new RowStructuralRefreshEvent(getUnderlyingLayer()); @@ -90,7 +90,6 @@ protected Runnable getEventNotifier() { } fireEventFromSWTDisplayThread(layerEvent); - GlazedListsEventLayer.this.eventsToProcess = false; GlazedListsEventLayer.this.structuralChangeEventsToProcess = false; } }; @@ -106,7 +105,7 @@ public void listChanged(ListEvent event) { this.structuralChangeEventsToProcess = true; } } - this.eventsToProcess = true; + this.eventsToProcess.set(true); } // PropertyChangeListener @@ -232,7 +231,7 @@ public boolean isActive() { * @since 1.6 */ public void discardEventsToProcess() { - this.eventsToProcess = false; + this.eventsToProcess.set(false); this.structuralChangeEventsToProcess = false; }