[databinding] ObservablesManager does not dispose observables from disposed context [message #481412] |
Thu, 20 August 2009 20:32 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
ObservablesManager does not dispose observables from a DataBindingContext if
the context is disposed first. Is this a bug? Or is it by design that the
OM should be disposed first? To me, it is more intuitive to dispose the
bindings before the underlying observables.
To demonstrate, the following test fails where indicated, i.e. the
observables are never disposed:
@Test
public void testDispose() {
DefaultRealm realm = new DefaultRealm();
ObservablesManager manager = new ObservablesManager();
DataBindingContext context = new DataBindingContext();
manager.addObservablesFromContext(context, true, true);
WritableValue value1 = WritableValue.withValueType(String.class);
WritableValue value2 = WritableValue.withValueType(String.class);
Binding binding = context.bindValue(
value1,
value2);
context.dispose();
manager.dispose();
assertThat(binding.isDisposed(), is(true));
assertThat(value1.isDisposed(), is(true)); // FAILS
assertThat(value2.isDisposed(), is(true));
realm.dispose();
}
|
|
|
Re: [databinding] ObservablesManager does not dispose observables from disposed context [message #481414 is a reply to message #481412] |
Thu, 20 August 2009 21:15 |
Matthew Hall Messages: 368 Registered: July 2009 |
Senior Member |
|
|
Will,
This is a really good point. Would you file a bug?
Matthew
Will Horn wrote:
> ObservablesManager does not dispose observables from a
> DataBindingContext if the context is disposed first. Is this a bug? Or
> is it by design that the OM should be disposed first? To me, it is more
> intuitive to dispose the bindings before the underlying observables.
>
> To demonstrate, the following test fails where indicated, i.e. the
> observables are never disposed:
>
> @Test
> public void testDispose() {
> DefaultRealm realm = new DefaultRealm();
>
> ObservablesManager manager = new ObservablesManager();
> DataBindingContext context = new DataBindingContext();
> manager.addObservablesFromContext(context, true, true);
>
> WritableValue value1 = WritableValue.withValueType(String.class);
> WritableValue value2 = WritableValue.withValueType(String.class);
> Binding binding = context.bindValue(
> value1,
> value2);
>
> context.dispose();
> manager.dispose();
>
> assertThat(binding.isDisposed(), is(true));
> assertThat(value1.isDisposed(), is(true)); // FAILS
> assertThat(value2.isDisposed(), is(true));
>
> realm.dispose();
> }
|
|
|
Re: [databinding] ObservablesManager does not dispose observables from disposed context [message #481424 is a reply to message #481414] |
Thu, 20 August 2009 22:25 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
http://bugs.eclipse.org/287247
"Matthew Hall" <matthall@woodcraftmill.com> wrote in message
news:h6keed$r3r$1@build.eclipse.org...
> Will,
>
> This is a really good point. Would you file a bug?
>
> Matthew
>
> Will Horn wrote:
>> ObservablesManager does not dispose observables from a DataBindingContext
>> if the context is disposed first. Is this a bug? Or is it by design
>> that the OM should be disposed first? To me, it is more intuitive to
>> dispose the bindings before the underlying observables.
>>
>> To demonstrate, the following test fails where indicated, i.e. the
>> observables are never disposed:
>>
>> @Test
>> public void testDispose() {
>> DefaultRealm realm = new DefaultRealm();
>>
>> ObservablesManager manager = new ObservablesManager();
>> DataBindingContext context = new DataBindingContext();
>> manager.addObservablesFromContext(context, true, true);
>>
>> WritableValue value1 = WritableValue.withValueType(String.class);
>> WritableValue value2 = WritableValue.withValueType(String.class);
>> Binding binding = context.bindValue(
>> value1,
>> value2);
>>
>> context.dispose();
>> manager.dispose();
>>
>> assertThat(binding.isDisposed(), is(true));
>> assertThat(value1.isDisposed(), is(true)); // FAILS
>> assertThat(value2.isDisposed(), is(true));
>>
>> realm.dispose();
>> }
|
|
|
Powered by
FUDForum. Page generated in 0.03976 seconds