From 6d3904c0e2dae72cc93b3ae2f2b29ed669c26fc6 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 17 Nov 2008 23:06:30 +0000 Subject: [PATCH] * ./hurricane/src/hurricane : - Bug : memory leak in Query.h. When we do try a levelDown() remove the Instance locator that have been created (and is not valid). - To trace the numbers of Instances Locator add a counter inside the QuadTree. The code is commented but could be useful in case of another memory leak... --- hurricane/src/hurricane/QuadTree.cpp | 15 +++++++++++++++ hurricane/src/hurricane/hurricane/QuadTree.h | 1 + hurricane/src/hurricane/hurricane/Query.h | 3 ++- hurricane/src/hviewer/CellWidget.cpp | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hurricane/src/hurricane/QuadTree.cpp b/hurricane/src/hurricane/QuadTree.cpp index 4c487e14..49db4dd8 100644 --- a/hurricane/src/hurricane/QuadTree.cpp +++ b/hurricane/src/hurricane/QuadTree.cpp @@ -110,10 +110,12 @@ class QuadTree_GosUnder : public Collection { private: Box _area; private: QuadTree* _currentQuadTree; private: GoLocator _goLocator; + //private: static size_t _allocateds; public: Locator(); public: Locator(const QuadTree* quadTree, const Box& area); public: Locator(const Locator& locator); + //public: ~Locator() { _allocateds--; } public: Locator& operator=(const Locator& locator); @@ -123,6 +125,7 @@ class QuadTree_GosUnder : public Collection { public: virtual bool isValid() const; public: virtual void progress(); + //public: static size_t getAllocateds() { return _allocateds; } public: virtual string _getString() const; @@ -160,6 +163,9 @@ class QuadTree_GosUnder : public Collection { }; +//size_t QuadTree_GosUnder::Locator::_allocateds = 0; + + // **************************************************************************************************** // QuadTree declaration @@ -204,6 +210,12 @@ QuadTree::~QuadTree() if (_lrChild) delete _lrChild; } +//size_t QuadTree::getLocatorAllocateds () +// ************************************** +//{ +// return QuadTree_GosUnder::Locator::getAllocateds(); +//} + const Box& QuadTree::getBoundingBox() const // **************************************** { @@ -731,6 +743,7 @@ QuadTree_GosUnder::Locator::Locator() _currentQuadTree(NULL), _goLocator() { + //_allocateds++; } QuadTree_GosUnder::Locator::Locator(const QuadTree* quadTree, const Box& area) @@ -741,6 +754,7 @@ QuadTree_GosUnder::Locator::Locator(const QuadTree* quadTree, const Box& area) _currentQuadTree(NULL), _goLocator() { + //_allocateds++; if (_quadTree && !_area.isEmpty()) { _currentQuadTree = _quadTree->_getFirstQuadTree(_area); if (_currentQuadTree) { @@ -758,6 +772,7 @@ QuadTree_GosUnder::Locator::Locator(const Locator& locator) _currentQuadTree(locator._currentQuadTree), _goLocator(locator._goLocator) { + //_allocateds++; } QuadTree_GosUnder::Locator& QuadTree_GosUnder::Locator::operator=(const Locator& locator) diff --git a/hurricane/src/hurricane/hurricane/QuadTree.h b/hurricane/src/hurricane/hurricane/QuadTree.h index 71a097f9..8fe32a5d 100644 --- a/hurricane/src/hurricane/hurricane/QuadTree.h +++ b/hurricane/src/hurricane/hurricane/QuadTree.h @@ -72,6 +72,7 @@ class QuadTree { // Accessors // ********* + //public: static size_t getLocatorAllocateds (); public: const Box& getBoundingBox() const; public: Gos getGos() const; public: Gos getGosUnder(const Box& area) const; diff --git a/hurricane/src/hurricane/hurricane/Query.h b/hurricane/src/hurricane/hurricane/Query.h index 35576a99..0c458846 100644 --- a/hurricane/src/hurricane/hurricane/Query.h +++ b/hurricane/src/hurricane/hurricane/Query.h @@ -243,7 +243,8 @@ namespace Hurricane { //_tab++; return true; - } + } else + delete locator; return false; } diff --git a/hurricane/src/hviewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp index 61ee6e03..63d70d78 100644 --- a/hurricane/src/hviewer/CellWidget.cpp +++ b/hurricane/src/hviewer/CellWidget.cpp @@ -589,6 +589,7 @@ namespace Hurricane { _drawingQuery.doQuery (); } } + if ( isDrawableLayer("boundaries") ) { _drawingPlanes.setPen ( Graphics::getPen ("boundaries",darkening) ); _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",darkening) );