Merge lp:~daniel-stehn/forssim/MemoryLeakFixInAHapticDrillForce into lp:forssim

Proposed by Daniel Stehn
Status: Merged
Merged at revision: not available
Proposed branch: lp:~daniel-stehn/forssim/MemoryLeakFixInAHapticDrillForce
Merge into: lp:forssim
Diff against target: None lines
To merge this branch: bzr merge lp:~daniel-stehn/forssim/MemoryLeakFixInAHapticDrillForce
Reviewer Review Type Date Requested Status
Forsslund Systems Pending
Review via email: mp+11600@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Stehn (daniel-stehn) wrote :

Added a destructor for the class AHapticDrillForce that deletes a pointer that never was destructed.

In ADrillForce::traverseSG( H3D::TraverseInfo &ti ) a pointer "generated_force" is allocated. This pointer becomes a part of another pointer (AHapticDrillForce), that is passed into the H3D::TraverseInfo reference.

AHapticDrillForce was responsible to clear the memory allocated by the generated_force pointer, but it didn't. Now there is a destructor that does the cleaning up.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/AHapticDrillForce.cpp'
2--- src/AHapticDrillForce.cpp 2009-03-13 15:10:45 +0000
3+++ src/AHapticDrillForce.cpp 2009-09-11 12:08:46 +0000
4@@ -44,6 +44,13 @@
5 bitRadius( _bitRadius){
6 }
7
8+AHapticDrillForce::~AHapticDrillForce()
9+{
10+ //Need to delete generated_force which is allocated in ADrillForce::traverseSG
11+ if( generated_force )
12+ delete generated_force;
13+}
14+
15
16 HAPI::Vec3 AHapticDrillForce::evaluate_forces(HAPI::Vec3 probe_position)
17 {
18
19=== modified file 'src/AHapticDrillForce.h'
20--- src/AHapticDrillForce.h 2009-03-13 15:10:45 +0000
21+++ src/AHapticDrillForce.h 2009-09-11 12:08:46 +0000
22@@ -70,6 +70,8 @@
23 double _drillFactor,
24 double _bitRadius);
25
26+ virtual ~AHapticDrillForce();
27+
28 /**
29 * The force of the EffectOutput will be the force of the force field.
30 */

Subscribers

People subscribed via source and target branches