Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rhino): ensure more robust expiration checks in rhino #311

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -220,6 +224,12 @@ await Commands
/// </summary>
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<string> expiredSenderIds = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading