Fix memory leak in sketcher view provider

This commit is contained in:
wmayer 2012-11-14 15:04:14 +01:00
parent 8952058a2b
commit d2ac422f68
2 changed files with 10 additions and 4 deletions

View File

@ -265,10 +265,14 @@ protected:
std::vector<std::string> getDisplayMaskModes() const;
void setDefaultMode(int);
//@}
/// Helper method to get picked entities while editing
/** Helper method to get picked entities while editing.
* It's in the responsibility of the caller to delete the returned instance.
*/
SoPickedPoint* getPointOnRay(const SbVec2s& pos,
const View3DInventorViewer* viewer) const;
/// Helper method to get picked entities while editing
/** Helper method to get picked entities while editing.
* It's in the responsibility of the caller to delete the returned instance.
*/
SoPickedPoint* getPointOnRay(const SbVec3f& pos, const SbVec3f& dir,
const View3DInventorViewer* viewer) const;
/// Reimplemented from subclass

View File

@ -68,6 +68,7 @@
#endif
#include <Inventor/SbTime.h>
#include <boost/scoped_ptr.hpp>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Tools.h>
@ -362,7 +363,8 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
SbVec3f point = viewer->getPointOnScreen(cursorPos);
SbVec3f normal = viewer->getViewDirection();
SoPickedPoint *pp = this->getPointOnRay(cursorPos, viewer);
// use scoped_ptr to make sure that instance gets deleted in all cases
boost::scoped_ptr<SoPickedPoint> pp(this->getPointOnRay(cursorPos, viewer));
// Radius maximum to allow double click event
const int dblClickRadius = 5;
@ -784,9 +786,9 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
Mode!=STATUS_SKETCH_DragConstraint) {
SoPickedPoint *pp = this->getPointOnRay(cursorPos, viewer);
int PtIndex,GeoIndex,ConstrIndex,CrossIndex;
preselectChanged = detectPreselection(pp,PtIndex,GeoIndex,ConstrIndex,CrossIndex);
delete pp;
}
switch (Mode) {