Results 1 to 5 of 5

Thread: NPE & weak references when using toolbars

  1. #1

    Default NPE & weak references when using toolbars

    Hello,

    I have a problem with the toolbar buttons. I bind a command to a toolbar button and a menu entry, depending on certain events I enable or disable the command, enabling or disabling the corresponding components, but after a while I get a NullPointerException because the command manager uses weak references and the GC deallocates the buttons.

    What am I doing wrong?

    Tks
    Catalin

  2. #2
    Join Date
    Aug 2004
    Posts
    203

    Default

    Do You use TargetableActionCommand
    If yes, then you have problem with ApplicationPage@fireFocusGained/FireFocusLost
    It realocate TargetableActionCommand - try synchronize with this methods or extend DefaultApplicationPage and exclude this methods

    regards

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Hmm... interesting. And these buttons are referenced by the containers containing them? If that's the case, I don't see how they could be garbage collected. We certainly need a JIRA issue for this if this indeed is happening consistently.

    Keith
    Keith Donald
    Core Spring Development Team

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    This is caused by some very whacky code in CommandFaceButtonManager ;-) I'm sitting on a patch but have not committed.

    Though this NPE can only happen if the button GCd so I suspect something is throwing away and recreating the toolbar or menu in this case. I hit it when I was throwing away popup menus.

    I'll commit the patch now.

    Ollie

  5. #5

    Default

    I tested the patch, and it works.
    tks a lot!

    Catalin

Similar Threads

  1. Replies: 3
    Last Post: Jan 11th, 2007, 04:30 AM
  2. not so Singletons, and Cyclic references
    By Ian Johnson in forum Container
    Replies: 0
    Last Post: May 23rd, 2005, 04:18 PM
  3. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  4. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •