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

fixed owner null bug #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fixed owner null bug #30

wants to merge 1 commit into from

Conversation

dhindrik
Copy link
Collaborator

No description provided.

@johankson
Copy link
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
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
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?

@@ -334,6 +346,7 @@ public static TinyEventArgs PublishControlled<T>(string channel, T instance, Act
if (subscription.Owner.Target == null)
{
subscriptionsToRemove.Add(subscription);
continue;
Copy link
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
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
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