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

MemoryPool checks if the item it's returning is null or not. #34

Merged
merged 1 commit into from
May 19, 2022

Conversation

pnarimani
Copy link

Added a simple check to pool to make sure that pool doesn't return or accept null items.

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • No compiler errors or warnings

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

  1. You return an object to pool
  2. Destroy the object
  3. Pool doesn't check if the object is destroyed and will return the null object in Spawn method.

What is the new behavior?

Pool will check if the item that is about to be returned is null or not.

Does this introduce a breaking change?

  • Yes
  • No

On which Unity version has this been tested?

  • 2021 LTS

Scripting backend:

  • Mono
  • IL2CPP

return true;

#if !NOT_UNITY3D
// This is very weird but sometimes when you check a component's value to see if it's null or not,
Copy link
Owner

Choose a reason for hiding this comment

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

I see! Good comment. And solution.

@Mathijs-Bakker Mathijs-Bakker merged commit 9b31a85 into Mathijs-Bakker:master May 19, 2022
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