[databinding] unable to dispose observable except from DataBindingContext validation realm [message #20634] |
Tue, 14 July 2009 16:50  |
Eclipse User |
|
|
|
A ListBinding must be disposed in the DataBindingContext validation realm
since the dispose method calls remove on the "bindings" WritableList.
However, a ListBinding also installs a dispose listener on both the target
and model observables. Therefore, if a model observable is involved in a
binding, it cannot be disposed except from the DataBindingContext validation
realm. Is this intended? Test code below.
-Will
final Exchanger<IObservableList> mModelExchanger = new
Exchanger<IObservableList>();
final CountDownLatch mModelReadyToDispose = new CountDownLatch(1);
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
try {
ThreadRealm realm = new ThreadRealm(); // ThreadRealm
from JFace tests
realm.init(Thread.currentThread());
WritableList model = new WritableList(realm,
new ArrayList<Object>(), String.class);
mModelExchanger.exchange(model);
mModelReadyToDispose.await();
model.dispose(); // throws AssertionFailedException
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
Display d = new Display();
Realm.runWithDefault(SWTObservables.getRealm(d), new Runnable() {
@Override
public void run() {
try {
WritableList target =
WritableList.withElementType(String.class);
DataBindingContext dbc = new DataBindingContext();
dbc.bindList(target, mModelExchanger.exchange(null));
mModelReadyToDispose.countDown();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
future.get(); // propagates the AssertionFailedException
executor.shutdownNow();
d.dispose();
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06870 seconds