diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Bindings/RhinoSendBinding.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Bindings/RhinoSendBinding.cs index 0670789a..698fe7c2 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Bindings/RhinoSendBinding.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Bindings/RhinoSendBinding.cs @@ -97,10 +97,11 @@ private void SubscribeToRhinoEvents() _topLevelExceptionHandler.CatchUnhandled(() => { // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } + // These events always happen in a doc. Why guard agains a null doc? + // if (!_store.IsDocumentInit) + // { + // return; + // } ChangedObjectIds[e.ObjectId.ToString()] = 1; _idleManager.SubscribeToIdle(nameof(RhinoSendBinding), RunExpirationChecks); @@ -110,10 +111,11 @@ private void SubscribeToRhinoEvents() _topLevelExceptionHandler.CatchUnhandled(() => { // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } + // These events always happen in a doc. Why guard agains a null doc? + // if (!_store.IsDocumentInit) + // { + // return; + // } ChangedObjectIds[e.ObjectId.ToString()] = 1; _idleManager.SubscribeToIdle(nameof(RhinoSendBinding), RunExpirationChecks); @@ -123,10 +125,11 @@ private void SubscribeToRhinoEvents() _topLevelExceptionHandler.CatchUnhandled(() => { // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } + // These events always happen in a doc. Why guard agains a null doc? + // if (!_store.IsDocumentInit) + // { + // return; + // } // NOTE: not sure yet we want to track every attribute changes yet. TBD if (e.OldAttributes.LayerIndex != e.NewAttributes.LayerIndex) @@ -140,10 +143,11 @@ private void SubscribeToRhinoEvents() _topLevelExceptionHandler.CatchUnhandled(() => { // NOTE: This does not work if rhino starts and opens a blank doc; - if (!_store.IsDocumentInit) - { - return; - } + // These events always happen in a doc. Why guard agains a null doc? + // if (!_store.IsDocumentInit) + // { + // return; + // } ChangedObjectIds[e.NewRhinoObject.Id.ToString()] = 1; ChangedObjectIds[e.OldRhinoObject.Id.ToString()] = 1; @@ -220,6 +224,12 @@ await Commands /// private async Task RunExpirationChecks() { + // Note: added here a guard against executing this if there's no active doc present. + if (RhinoDoc.ActiveDoc == null) + { + _logger.LogError("Rhino expiration checks were running without an active doc."); + return; + } var senders = _store.GetSenders(); string[] objectIdsList = ChangedObjectIds.Keys.ToArray(); // NOTE: could not copy to array happens here List expiredSenderIds = new(); diff --git a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Plugin/Speckle.Connectors.RhinoPlugin.cs b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Plugin/Speckle.Connectors.RhinoPlugin.cs index 66e1690d..a172c693 100644 --- a/Connectors/Rhino/Speckle.Connectors.RhinoShared/Plugin/Speckle.Connectors.RhinoPlugin.cs +++ b/Connectors/Rhino/Speckle.Connectors.RhinoShared/Plugin/Speckle.Connectors.RhinoPlugin.cs @@ -50,7 +50,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) services.AddRhino(); services.AddRhinoConverters(); - // but the Rhino connector has `.rhp` as it's extension. + // but the Rhino connector has `.rhp` as it is extension. Container = services.BuildServiceProvider(); Container.UseDUI();