{"action":"created","issue":{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/1213","repository_url":"https://api.github.com/repos/DynamoDS/DynamoRevit","labels_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/1213/labels{/name}","comments_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/1213/comments","events_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/1213/events","html_url":"https://github.com/DynamoDS/DynamoRevit/pull/1213","id":172468821,"number":1213,"title":"MAGN-10577: Fix NullReferenceException from SetRunEnabledBasedOnContext","user":{"login":"sharadkjaiswal","id":1754137,"avatar_url":"https://avatars.githubusercontent.com/u/1754137?v=3","gravatar_id":"","url":"https://api.github.com/users/sharadkjaiswal","html_url":"https://github.com/sharadkjaiswal","followers_url":"https://api.github.com/users/sharadkjaiswal/followers","following_url":"https://api.github.com/users/sharadkjaiswal/following{/other_user}","gists_url":"https://api.github.com/users/sharadkjaiswal/gists{/gist_id}","starred_url":"https://api.github.com/users/sharadkjaiswal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharadkjaiswal/subscriptions","organizations_url":"https://api.github.com/users/sharadkjaiswal/orgs","repos_url":"https://api.github.com/users/sharadkjaiswal/repos","events_url":"https://api.github.com/users/sharadkjaiswal/events{/privacy}","received_events_url":"https://api.github.com/users/sharadkjaiswal/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/labels/PTAL","name":"PTAL","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"Randy-Ma","id":5584246,"avatar_url":"https://avatars.githubusercontent.com/u/5584246?v=3","gravatar_id":"","url":"https://api.github.com/users/Randy-Ma","html_url":"https://github.com/Randy-Ma","followers_url":"https://api.github.com/users/Randy-Ma/followers","following_url":"https://api.github.com/users/Randy-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Randy-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Randy-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Randy-Ma/subscriptions","organizations_url":"https://api.github.com/users/Randy-Ma/orgs","repos_url":"https://api.github.com/users/Randy-Ma/repos","events_url":"https://api.github.com/users/Randy-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Randy-Ma/received_events","type":"User","site_admin":false},"assignees":[{"login":"Randy-Ma","id":5584246,"avatar_url":"https://avatars.githubusercontent.com/u/5584246?v=3","gravatar_id":"","url":"https://api.github.com/users/Randy-Ma","html_url":"https://github.com/Randy-Ma","followers_url":"https://api.github.com/users/Randy-Ma/followers","following_url":"https://api.github.com/users/Randy-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Randy-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Randy-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Randy-Ma/subscriptions","organizations_url":"https://api.github.com/users/Randy-Ma/orgs","repos_url":"https://api.github.com/users/Randy-Ma/repos","events_url":"https://api.github.com/users/Randy-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Randy-Ma/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-08-22T14:35:59Z","updated_at":"2016-08-23T08:40:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/1213","html_url":"https://github.com/DynamoDS/DynamoRevit/pull/1213","diff_url":"https://github.com/DynamoDS/DynamoRevit/pull/1213.diff","patch_url":"https://github.com/DynamoDS/DynamoRevit/pull/1213.patch"},"body":"### Purpose\r\n\r\n- This PR fixes System.NullReferenceException is thrown while starting Dynamo and the current document is not yet active or when a new view is added to a Revit document other than the one Dynamo session was bound to.\r\n\r\n`System.NullReferenceException at Dynamo.Applications.Models.RevitDynamoModel.SetRunEnabledBasedOnContext(View newView, Boolean raiseRevitContextAvailableEvent) at  Dynamo.Applications.Models.RevitDynamoModel.OnWorkspaceAdded(WorkspaceModel workspace) at  Dynamo.Models.DynamoModel.AddHomeWorkspace() at  Dynamo.Models.DynamoModel..ctor(IStartConfiguration config) at  Dynamo.Applications.Models.RevitDynamoModel..ctor(IRevitStartConfiguration configuration) at  Dynamo.Applications.Models.RevitDynamoModel.Start(IRevitStartConfiguration configuration) at  Dynamo.Applications.DynamoRevit.InitializeCoreModel(DynamoRevitCommandData commandData) at  Dynamo.Applications.DynamoRevit.ExecuteCommand(DynamoRevitCommandData commandData)`\r\n\r\n- This also fixes another crash while launching Dynamo subsequently because DynamoRevitModel was not shut down properly and hence analytics service was throwing an exception while initializing the analytics service because the previous session was not cleared properly. Ensure that ShutDown is called on the DynamoModel. \r\n\r\n`System.InvalidOperationException at Autodesk.Analytics.Core.Service.Register(IEventTrackerFactory factory) at Dynamo.Logging.DynamoAnalyticsSession.Start(DynamoModel model) at Dynamo.Logging.DynamoAnalyticsClient.Start(DynamoModel dynamoModel) at Dynamo.Logging.Analytics.Start(DynamoModel model) at Dynamo.Models.DynamoModel.InitializeInstrumentationLogger() at Dynamo.Models.DynamoModel..ctor(IStartConfiguration config) at Dynamo.Applications.Models.RevitDynamoModel..ctor(IRevitStartConfiguration configuration) at Dynamo.Applications.Models.RevitDynamoModel.Start(IRevitStartConfiguration configuration) at Dynamo.Applications.DynamoRevit.InitializeCoreModel(DynamoRevitCommandData commandData) at Dynamo.Applications.DynamoRevit.ExecuteCommand(DynamoRevitCommandData commandData)`\r\n\r\n### Declarations\r\n\r\nCheck these if you believe they are true\r\n\r\n- [x] The code base is in a better state after this PR\r\n- [ ] Is documented according to the [standards](https://github.com/DynamoDS/Dynamo/wiki/Coding-Standards)\r\n- [ ] The level of testing this PR includes is appropriate\r\n- [ ] User facing strings, if any, are extracted into `*.resx` files\r\n- [ ] Snapshot of UI changes, if any.\r\n\r\n### Reviewers\r\n\r\n@Randy-Ma \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/comments/241665124","html_url":"https://github.com/DynamoDS/DynamoRevit/pull/1213#issuecomment-241665124","issue_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/1213","id":241665124,"user":{"login":"Randy-Ma","id":5584246,"avatar_url":"https://avatars.githubusercontent.com/u/5584246?v=3","gravatar_id":"","url":"https://api.github.com/users/Randy-Ma","html_url":"https://github.com/Randy-Ma","followers_url":"https://api.github.com/users/Randy-Ma/followers","following_url":"https://api.github.com/users/Randy-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Randy-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Randy-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Randy-Ma/subscriptions","organizations_url":"https://api.github.com/users/Randy-Ma/orgs","repos_url":"https://api.github.com/users/Randy-Ma/repos","events_url":"https://api.github.com/users/Randy-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Randy-Ma/received_events","type":"User","site_admin":false},"created_at":"2016-08-23T08:40:10Z","updated_at":"2016-08-23T08:40:10Z","body":"From the callstack when the crash happens, it is hard to say the crash happens exactly because newView is null. But it is most likey the case as I can see. Other than this, LGTM."}}
{"actor":{"display_login":"Randy-Ma"}}