Skip to content

Conversation

@rerpha
Copy link
Contributor

@rerpha rerpha commented Aug 2, 2022

The exceptions occurred due to the finalizer method of the BlocksMenu class trying to remove a listener which had already been disposed of if the menu was not open.

There is a slight difference in the way that the 'edit host configuration/component' menu item is now greyed out instead of invisible when a user does not have write access to a block, though I think this is more clear.

@Tom-Willemsen
Copy link
Member

The exceptions occurred due to the finalizer method of the BlocksMenu class trying to remove a listener which had already been disposed of if the menu was not open.

This isn't quite true - the exceptions occured due to attempting to use a menu (via getMenuItems) from a listener while that menu isn't open - causing a widgetDisposed error, since the menu has been disposed of by eclipse.

There was a separate issue relating to the finalizer, which would never have run because the listener itself has a reference back to this, and therefore the class would previously have leaked listeners (and therefore memory). This is fixed now by only ever adding one listener, not one listener each time the menu is opened. Note that finalize usage is pretty much always wrong except when doing things with native methods or WeakReference or other very specialized uses.

@JackEAllen JackEAllen self-requested a review August 2, 2022 13:44
Copy link
Contributor

@JackEAllen JackEAllen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as expected. I can't edit the host configuration on another instrument as to be expected, but can on my own dev instrument setup.

I have left a few nit-picks which I would like to get your opinion on.

@JackEAllen
Copy link
Contributor

When this issue is ready for merging, The changes should be squashed and merged to changes are easier to cherry pick into release.

@JackEAllen
Copy link
Contributor

From a quick test, still behaves as expected.

Copy link
Contributor

@JackEAllen JackEAllen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@JackEAllen JackEAllen merged commit f05f3dc into master Aug 2, 2022
@JackEAllen JackEAllen deleted the Ticket7269_edit_host_config_menu_broken branch August 2, 2022 14:51
rerpha added a commit that referenced this pull request Aug 2, 2022
* fixing 'edit host configuration' menu item - due to listeners on object being disposed of when menu not open

* review comments

* further review comments, remove editBlockAction as instance var, return from createEditBlockLabelAndAction

(cherry picked from commit f05f3dc)
rerpha added a commit that referenced this pull request Aug 3, 2022
* fixing 'edit host configuration' menu item - due to listeners on object being disposed of when menu not open

* review comments

* further review comments, remove editBlockAction as instance var, return from createEditBlockLabelAndAction

(cherry picked from commit f05f3dc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants