Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [databinding] ObservablesManager does not dispose observables from disposed context
[databinding] ObservablesManager does not dispose observables from disposed context [message #481412] Thu, 20 August 2009 20:32 Go to next message
Will Horn is currently offline Will HornFriend
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 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
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 Go to previous message
Will Horn is currently offline Will HornFriend
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();
>> }
Previous Topic:Databinding of CheckboxTableViewer
Next Topic:Changing the background color of the wizard dialog
Goto Forum:
  


Current Time: Tue Sep 24 23:01:17 GMT 2024

Powered by FUDForum. Page generated in 0.03976 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top