diff --git a/src/Gui/ViewProvider.h b/src/Gui/ViewProvider.h index 0aeeee4e3..05b22dbc9 100644 --- a/src/Gui/ViewProvider.h +++ b/src/Gui/ViewProvider.h @@ -265,10 +265,14 @@ protected: std::vector 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 diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 484883f60..258f4ea51 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -68,6 +68,7 @@ #endif #include +#include /// Here the FreeCAD includes sorted by Base,App,Gui...... #include @@ -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 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) {