From: ptv Date: Wed, 4 Oct 2006 13:06:01 +0000 (+0000) Subject: remove memory leak X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9d680ef2d4367740f689b593298a264f441ef93c;p=modules%2Fgui.git remove memory leak --- diff --git a/src/GLViewer/GLViewer_BaseObjects.cxx b/src/GLViewer/GLViewer_BaseObjects.cxx index 338543ee3..deafa1e9a 100644 --- a/src/GLViewer/GLViewer_BaseObjects.cxx +++ b/src/GLViewer/GLViewer_BaseObjects.cxx @@ -568,14 +568,14 @@ GLboolean GLViewer_MarkerSet::unselect() \return update object rectangle Does not equal getRect() if object have a persistence to some viewer transformations */ -GLViewer_Rect* GLViewer_MarkerSet::getUpdateRect() +GLViewer_Rect GLViewer_MarkerSet::getUpdateRect() { - GLViewer_Rect* rect = new GLViewer_Rect(); + GLViewer_Rect rect; - rect->setLeft( myRect->left() + myXGap - myMarkerSize / myXScale ); - rect->setTop( myRect->top() + myYGap + myMarkerSize / myYScale ); - rect->setRight( myRect->right() - myXGap + myMarkerSize / myXScale ); - rect->setBottom( myRect->bottom() - myYGap - myMarkerSize / myYScale ); + rect.setLeft( myRect->left() + myXGap - myMarkerSize / myXScale ); + rect.setTop( myRect->top() + myYGap + myMarkerSize / myYScale ); + rect.setRight( myRect->right() - myXGap + myMarkerSize / myXScale ); + rect.setBottom( myRect->bottom() - myYGap - myMarkerSize / myYScale ); //cout << " Additional tolerance " << myMarkerSize / myYScale << endl; //rect->setLeft( myRect->left() - myMarkerSize / myXScale ); //rect->setTop( myRect->top() - myMarkerSize / myYScale ); @@ -977,14 +977,14 @@ void GLViewer_Polyline::compute() \return update object rectangle Does not equal getRect() if object have a persistence to some viewer transformations */ -GLViewer_Rect* GLViewer_Polyline::getUpdateRect() +GLViewer_Rect GLViewer_Polyline::getUpdateRect() { - GLViewer_Rect* rect = new GLViewer_Rect(); + GLViewer_Rect rect; - rect->setLeft( myRect->left() - myXGap ); - rect->setTop( myRect->top() + myYGap ); - rect->setRight( myRect->right() + myXGap ); - rect->setBottom( myRect->bottom() - myYGap ); + rect.setLeft( myRect->left() - myXGap ); + rect.setTop( myRect->top() + myYGap ); + rect.setRight( myRect->right() + myXGap ); + rect.setBottom( myRect->bottom() - myYGap ); return rect; } @@ -1519,18 +1519,18 @@ void GLViewer_TextObject::setDrawer( GLViewer_Drawer* theDrawer ) \return update object rectangle Does not equal getRect() if object have a persistence to some viewer transformations */ -GLViewer_Rect* GLViewer_TextObject::getUpdateRect() +GLViewer_Rect GLViewer_TextObject::getUpdateRect() { - GLViewer_Rect* rect = new GLViewer_Rect(); + GLViewer_Rect rect; float xPos, yPos; QString aStr = myGLText->getText(); myGLText->getPosition( xPos, yPos ); - rect->setLeft( myRect->left() + myXGap - myWidth / myXScale ); - rect->setTop( myRect->top() + myYGap + myHeight / myYScale ); - rect->setRight( myRect->right() - myXGap + myWidth / myXScale ); - rect->setBottom( myRect->bottom() - myYGap - myHeight / myYScale ); + rect.setLeft( myRect->left() + myXGap - myWidth / myXScale ); + rect.setTop( myRect->top() + myYGap + myHeight / myYScale ); + rect.setRight( myRect->right() - myXGap + myWidth / myXScale ); + rect.setBottom( myRect->bottom() - myYGap - myHeight / myYScale ); return rect; } diff --git a/src/GLViewer/GLViewer_BaseObjects.h b/src/GLViewer/GLViewer_BaseObjects.h index c0f45d328..2a93ecc4c 100644 --- a/src/GLViewer/GLViewer_BaseObjects.h +++ b/src/GLViewer/GLViewer_BaseObjects.h @@ -59,7 +59,7 @@ public: GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); virtual GLboolean unselect(); - virtual GLViewer_Rect* getUpdateRect(); + virtual GLViewer_Rect getUpdateRect(); virtual void moveObject( float, float, bool fromGroup = false ); @@ -138,7 +138,7 @@ public: GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); virtual GLboolean unselect(); - virtual GLViewer_Rect* getUpdateRect(); + virtual GLViewer_Rect getUpdateRect(); virtual void moveObject( float, float, bool fromGroup = false ); @@ -223,7 +223,7 @@ public: GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); virtual GLboolean unselect(); - virtual GLViewer_Rect* getUpdateRect(); + virtual GLViewer_Rect getUpdateRect(); virtual void moveObject( float, float, bool fromGroup = false ); diff --git a/src/GLViewer/GLViewer_Context.cxx b/src/GLViewer/GLViewer_Context.cxx index 0383b0325..a0f6267c5 100644 --- a/src/GLViewer/GLViewer_Context.cxx +++ b/src/GLViewer/GLViewer_Context.cxx @@ -101,8 +101,8 @@ int GLViewer_Context::MoveTo( int xi, int yi, bool byCircle ) { GLViewer_Object* object = *it; - GLViewer_Rect* rect = object->getUpdateRect(); - if( rect->contains( GLViewer_Pnt( x, y ) ) ) + GLViewer_Rect rect = object->getUpdateRect(); + if( rect.contains( GLViewer_Pnt( x, y ) ) ) { onObject = GL_TRUE; object->highlight( x, y, myTolerance, GL_FALSE ); @@ -302,9 +302,9 @@ int GLViewer_Context::Select( bool Append, bool byCircle ) for( oit = myActiveObjects.begin(), oitEnd = myActiveObjects.end(); oit != oitEnd; ++oit ) { (*oit)->setScale( aXScale, aYScale ); - GLViewer_Rect* rect = (*oit)->getUpdateRect(); + GLViewer_Rect rect = (*oit)->getUpdateRect(); - if( rect->contains( GLViewer_Pnt( myXhigh, myXhigh ) ) ) + if( rect.contains( GLViewer_Pnt( myXhigh, myXhigh ) ) ) { (*oit)->select( myXhigh, myYhigh, myTolerance, GLViewer_Rect(), false, byCircle, Append ); isSel = (*oit)->isSelected(); diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 61faf8944..6ac66583e 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -131,7 +131,7 @@ public: virtual GLViewer_Rect* getRect() const { return myRect; } //! Returns update object rectangle /*! Does not equal getRect() if object have a persistence to some viewer transformations*/ - virtual GLViewer_Rect* getUpdateRect() = 0; + virtual GLViewer_Rect getUpdateRect() = 0; //! Installs scale factors virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }