|
|
Re: Exception during dispose in GlazedListsEventLayer [message #1446849 is a reply to message #1446813] |
Fri, 17 October 2014 11:53 |
Frank Mosebach Messages: 7 Registered: September 2014 |
Junior Member |
|
|
Hello,
we experienced a similar problem with a custom table layer implementation, where we schedule a task for firing a layer event to be executed on the Display thread, quite similar to what the GlazedListsEventLayer does (in line 128).
The problem is IMO that at the time when the scheduled task will actually be executed, the table may have already been disposed. As a consequence, when the table's ViewportLayer tries to handle the emitted event, it'll fail when trying to adjust the related scrollbars. Actually, the ViewportLayer knows that the table has been disposed at that time, it just doesn't consider that when handling the next layer event.
To fix the described problem, we replaced the standard ViewportLayer implementation with a subclass that overrides the "dispose" and "handleLayerEvent" as follows:
public final class SafeViewportLayer extends ViewportLayer {
private final AtomicBoolean disposed;
public SafeViewportLayer(final IUniqueIndexLayer underlyingLayer) {
super(underlyingLayer);
this.disposed = new AtomicBoolean();
}
@Override
public void dispose() {
if (disposed.compareAndSet(false, true)) {
super.dispose();
}
}
@Override
public void handleLayerEvent(final ILayerEvent event) {
if (!disposed.get()) {
super.handleLayerEvent(event);
}
}
}
Regards,
Frank
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03365 seconds