Skip to content

fixed owner null bug#30

Open
dhindrik wants to merge 1 commit into
mainfrom
owner-null
Open

fixed owner null bug#30
dhindrik wants to merge 1 commit into
mainfrom
owner-null

Conversation

@dhindrik

Copy link
Copy Markdown
Collaborator

No description provided.

@johankson

Copy link
Copy Markdown
Collaborator

What does this solve?

@@ -334,6 +346,7 @@ public static TinyEventArgs PublishControlled<T>(string channel, T instance, Act
if (subscription.Owner.Target == null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why doesn't just

subscriber.Owner?.Target == null

be enough? Instead of creating a static object? Just trying to understand.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nope, then it will think the owner is collected by GC. Maybe we should deprecate the method of not having an owner?

if (subscription.Owner.Target == null)
{
subscriptionsToRemove.Add(subscription);
continue;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why continue here? What happens if ActionWithArgumentAndArgs isn't null? Then it will not be called?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Because if it is null the object owning it is been collected by GC. And then we can remove that subscription

@johankson

Copy link
Copy Markdown
Collaborator

Missing unit-tests to verify the old and new logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants