{"action":"created","issue":{"url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/3923","repository_url":"https://api.github.com/repos/rubberduck-vba/Rubberduck","labels_url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/3923/labels{/name}","comments_url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/3923/comments","events_url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/3923/events","html_url":"https://github.com/rubberduck-vba/Rubberduck/pull/3923","id":313324503,"number":3923,"title":"Bring CommandBarButton events under control","user":{"login":"bclothier","id":2367644,"avatar_url":"https://avatars2.githubusercontent.com/u/2367644?v=4","gravatar_id":"","url":"https://api.github.com/users/bclothier","html_url":"https://github.com/bclothier","followers_url":"https://api.github.com/users/bclothier/followers","following_url":"https://api.github.com/users/bclothier/following{/other_user}","gists_url":"https://api.github.com/users/bclothier/gists{/gist_id}","starred_url":"https://api.github.com/users/bclothier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bclothier/subscriptions","organizations_url":"https://api.github.com/users/bclothier/orgs","repos_url":"https://api.github.com/users/bclothier/repos","events_url":"https://api.github.com/users/bclothier/events{/privacy}","received_events_url":"https://api.github.com/users/bclothier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-11T13:29:36Z","updated_at":"2018-04-12T03:39:28Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/pulls/3923","html_url":"https://github.com/rubberduck-vba/Rubberduck/pull/3923","diff_url":"https://github.com/rubberduck-vba/Rubberduck/pull/3923.diff","patch_url":"https://github.com/rubberduck-vba/Rubberduck/pull/3923.patch"},"body":"The PR applies the `SafeEventedComWrapper` to the `CommandBarButton` which supports a single `Click` event.\r\n\r\nNote that this created a diamond problem because `CommandBarButton` derives from `CommandBarBase` which in turns derives from `SafeComWrapper` and we need to derive from `SafeEventedComWrapper` instead. For now, I've chosen to (with apologies) copy-pasta the code and implement `SafeEventedWrapper`. A better long-term fix would be to have a private `CommandBarBase` field to pass all non-overriden methods to. \r\n\r\nThe real focus of the PR, however, is to make the event management of the `Click` event deterministic and can be controlled via the `VBEEvents` indirectly. \r\n\r\nThe button creation is done via the `CommandBarButtonFactory`, which originally was a static class but is now DI'd. The factory will maintain a list of buttons and listen to the `VBEEvents.EventTerminated` event to detach all buttons' events in a timely manner. Note that it does not dispose the buttons as we can't assume that it's appropriate to do so but we do ensure that the events are detached, making buttons useless. \r\n\r\nNote that this does not fix the unclean exit issue. "},"comment":{"url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/comments/380668236","html_url":"https://github.com/rubberduck-vba/Rubberduck/pull/3923#issuecomment-380668236","issue_url":"https://api.github.com/repos/rubberduck-vba/Rubberduck/issues/3923","id":380668236,"user":{"login":"WaynePhillipsEA","id":25738109,"avatar_url":"https://avatars1.githubusercontent.com/u/25738109?v=4","gravatar_id":"","url":"https://api.github.com/users/WaynePhillipsEA","html_url":"https://github.com/WaynePhillipsEA","followers_url":"https://api.github.com/users/WaynePhillipsEA/followers","following_url":"https://api.github.com/users/WaynePhillipsEA/following{/other_user}","gists_url":"https://api.github.com/users/WaynePhillipsEA/gists{/gist_id}","starred_url":"https://api.github.com/users/WaynePhillipsEA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WaynePhillipsEA/subscriptions","organizations_url":"https://api.github.com/users/WaynePhillipsEA/orgs","repos_url":"https://api.github.com/users/WaynePhillipsEA/repos","events_url":"https://api.github.com/users/WaynePhillipsEA/events{/privacy}","received_events_url":"https://api.github.com/users/WaynePhillipsEA/received_events","type":"User","site_admin":false},"created_at":"2018-04-12T03:39:27Z","updated_at":"2018-04-12T03:39:27Z","author_association":"CONTRIBUTOR","body":"If accessing the Parent was causing an access violation, that's a red flag... something is not right.   I would guess the order of destruction (... it suggests child elements not being deleted and released before their parent objects get the same treatment)"}}
{"actor":{"display_login":"WaynePhillipsEA"}}