-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix a leak in ogre2 ray query #866
Conversation
Signed-off-by: Shameek Ganguly <[email protected]>
Codecov Report
@@ Coverage Diff @@
## gz-rendering7 #866 +/- ##
==============================================
Coverage 77.14% 77.14%
==============================================
Files 170 170
Lines 14715 14720 +5
==============================================
+ Hits 11352 11356 +4
- Misses 3363 3364 +1
|
ogre2/src/Ogre2RayQuery.cc
Outdated
public: ~Ogre2RayQueryPrivate() { | ||
if (rayQuery != nullptr) { | ||
delete rayQuery; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about putting this in the Ogre2RayQuery
destructor? and use ogre's scene manager to destroy the query object:
diff --git a/ogre2/src/Ogre2RayQuery.cc b/ogre2/src/Ogre2RayQuery.cc
index 8d7684c9..8a9826c3 100644
--- a/ogre2/src/Ogre2RayQuery.cc
+++ b/ogre2/src/Ogre2RayQuery.cc
@@ -71,6 +71,16 @@ Ogre2RayQuery::Ogre2RayQuery()
//////////////////////////////////////////////////
Ogre2RayQuery::~Ogre2RayQuery()
{
+ if (this->dataPtr->rayQuery)
+ {
+ Ogre2ScenePtr ogreScene =
+ std::dynamic_pointer_cast<Ogre2Scene>(this->Scene());
+ if (ogreScene)
+ {
+ ogreScene->OgreSceneManager()->destroyQuery(this->dataPtr->rayQuery);
+ this->dataPtr->rayQuery = nullptr;
+ }
+ }
}
Signed-off-by: Shameek Ganguly <[email protected]>
Thanks Ian, updated the PR with your suggestion. |
Signed-off-by: Shameek Ganguly <[email protected]> Co-authored-by: Ian Chen <[email protected]>
No description provided.