Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Databinding throws NPE
Databinding throws NPE [message #332071] Thu, 02 October 2008 03:46 Go to next message
Eclipse UserFriend
Originally posted by: NOBODY.NOSPAM.COM

Hello Group,

I've run into the following problem, and am at the end of my wits. A data
model fires a property change event on PropertyChangeSupport to update the
UI. The window with the bound widgets is later disposed, and created again,
bound to the same data model instance. On subsequent attempts to fire the
property change, an NPE is thrown in ValueBinding. I put together a small
test case that reproduces the problem each and every time.

To those who are willing to look into this: run the test as a Java app in
Debug mode, and add the NullPointerException as a Java exception breakpoint.
The test displays a small window with a button; pressing the button brings
up another window with two widgets: a checkbox, and a text field. The text
field is initially disabled; clicking on the checkbox enables it. Close the
window and press the button again, then click the checkbox. This will cause
the NPE.

The culprit at the test code level is the
PropertyChangeSupport#firePropertyChange() call in the DataModel (line 22).
If it is commented out, the NPE disappears. Apparently, the
PropertyChangeSupport does not clear references to the defunct listeners on
the UI side. Unfortunately, I have not been able to track down the chain of
calls to see why this happens.

Any help or suggestions will be highly appreciated.

PS: I could wire up a disposal listener, and manually clear out all
listeners in the PropertyChangeSupport. But it seems to me that this is the
job of data binding, so I must be doing something wrong.

Thank you,

Alex Molochnikov
Kelman Technologies Inc.



Re: Databinding throws NPE [message #332089 is a reply to message #332071] Thu, 02 October 2008 15:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

On 10/1/2008 11:46 PM, Alex Molochnikov wrote:
> Hello Group,
>
> I've run into the following problem, and am at the end of my wits. A data
> model fires a property change event on PropertyChangeSupport to update the
> UI. The window with the bound widgets is later disposed, and created again,
> bound to the same data model instance. On subsequent attempts to fire the
> property change, an NPE is thrown in ValueBinding. I put together a small
> test case that reproduces the problem each and every time.

I don't have time to look at your code in detail, but if you are
disposing the UI and later re-attaching to the same model instance(s),
you have to make sure to dispose the Binding and the IObservable
instances that were created. If you don't there will be zombie listeners
left around linking the model and the (now disposed) UI widgets.

Hope this helps,
Eric


> To those who are willing to look into this: run the test as a Java app in
> Debug mode, and add the NullPointerException as a Java exception breakpoint.
> The test displays a small window with a button; pressing the button brings
> up another window with two widgets: a checkbox, and a text field. The text
> field is initially disabled; clicking on the checkbox enables it. Close the
> window and press the button again, then click the checkbox. This will cause
> the NPE.
>
> The culprit at the test code level is the
> PropertyChangeSupport#firePropertyChange() call in the DataModel (line 22).
> If it is commented out, the NPE disappears. Apparently, the
> PropertyChangeSupport does not clear references to the defunct listeners on
> the UI side. Unfortunately, I have not been able to track down the chain of
> calls to see why this happens.
>
> Any help or suggestions will be highly appreciated.
>
> PS: I could wire up a disposal listener, and manually clear out all
> listeners in the PropertyChangeSupport. But it seems to me that this is the
> job of data binding, so I must be doing something wrong.
>
> Thank you,
>
> Alex Molochnikov
> Kelman Technologies Inc.
>
>
Re: Databinding throws NPE [message #332091 is a reply to message #332089] Thu, 02 October 2008 16:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexm.xxx.yyy

Eric Rizzo wrote:
> On 10/1/2008 11:46 PM, Alex Molochnikov wrote:
> I don't have time to look at your code in detail, but if you are
> disposing the UI and later re-attaching to the same model instance(s),
> you have to make sure to dispose the Binding and the IObservable
> instances that were created. If you don't there will be zombie listeners
> left around linking the model and the (now disposed) UI widgets.
>
> Hope this helps,
> Eric

Eric,

Thank you for the response. You are right - disposing of the databinding
context as a whole took care of the NPE. I wired it up in the dispose
listener for the window, and the problem was solved.

Alex
Re: Databinding throws NPE [message #332095 is a reply to message #332091] Thu, 02 October 2008 18:34 Go to previous message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
You will still leak listeners if you only dispose of the data binding
context (which in turn disposes the bindings, but not the observables).
Have a look at ObservablesManager, it helps you dispose the observables as
well.

Boris

"Alex Molochnikov" <alexm@xxx.yyy> wrote in message
news:gc2s59$u78$1@build.eclipse.org...
> Eric Rizzo wrote:
>> On 10/1/2008 11:46 PM, Alex Molochnikov wrote:
>> I don't have time to look at your code in detail, but if you are
>> disposing the UI and later re-attaching to the same model instance(s),
>> you have to make sure to dispose the Binding and the IObservable
>> instances that were created. If you don't there will be zombie listeners
>> left around linking the model and the (now disposed) UI widgets.
>>
>> Hope this helps,
>> Eric
>
> Eric,
>
> Thank you for the response. You are right - disposing of the databinding
> context as a whole took care of the NPE. I wired it up in the dispose
> listener for the window, and the problem was solved.
>
> Alex
Previous Topic:display whitespace toggle shortcut
Next Topic:Embed Eclipse editor into Java Swing application?
Goto Forum:
  


Current Time: Fri Jul 05 03:29:08 GMT 2024

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

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

Back to the top