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

Fix a leak in ogre2 ray query #866

Merged
merged 3 commits into from
Jun 27, 2023
Merged

Conversation

shameekganguly
Copy link
Contributor

No description provided.

Signed-off-by: Shameek Ganguly <[email protected]>
@shameekganguly shameekganguly requested a review from iche033 as a code owner June 27, 2023 17:56
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jun 27, 2023
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Merging #866 (8e58cf7) into gz-rendering7 (537bcea) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 8e58cf7 differs from pull request most recent head add464d. Consider uploading reports for the commit add464d to get more accurate results

@@              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     
Impacted Files Coverage Δ
ogre2/src/Ogre2RayQuery.cc 63.41% <100.00%> (+1.55%) ⬆️

... and 1 file with indirect coverage changes

public: ~Ogre2RayQueryPrivate() {
if (rayQuery != nullptr) {
delete rayQuery;
}
Copy link
Contributor

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]>
@shameekganguly
Copy link
Contributor Author

Thanks Ian, updated the PR with your suggestion.

@iche033 iche033 merged commit 9f32fcc into gazebosim:gz-rendering7 Jun 27, 2023
mderbaso-deepx pushed a commit to DeepX-inc/gz-rendering that referenced this pull request Jun 4, 2024
Signed-off-by: Shameek Ganguly <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants