[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/marble/src/lib/geodata/parser
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2008-03-11 15:22:56
Message-ID: 1205248976.000681.23732.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 784516 by wildfox:
Add simple GeoNode object leak protection. Wold have spotted problems like those \
we've faced in GeoSceneSettings::property. Set DUMP_GEONODE_LEAKS to 1, to get a leak \
count report when deleting the document. Set to 2, to see when which objects are \
constructed/destructed. Setting to 1 is the default for now.
Result: no leaks on simple test files :-)
M +38 -1 GeoDocument.h
M +6 -0 GeoParser.cpp
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoDocument.h #784515:784516
@@ -24,15 +24,32 @@
#include "GeoTagHandler.h"
+// Set to a value greater than 0, to enable leak tracking of GeoNode objects
+// Set to a value greater than 1, to enable detailed tracking of \
construction/destruction of GeoNode objects +#define DUMP_GEONODE_LEAKS 1
+
/**
* @short A shared base class between GeoDataDocument/GeoSourceDocument
*/
class GeoDocument {
protected:
GeoDocument() { }
- virtual ~GeoDocument() { }
public:
+#if DUMP_GEONODE_LEAKS > 0
+ static unsigned long s_leakProtector;
+#endif
+
+ virtual ~GeoDocument()
+ {
+#if DUMP_GEONODE_LEAKS > 0
+ if (s_leakProtector != 0) {
+ fprintf(stderr, "Found %li GeoNode object LEAKS!\n", s_leakProtector);
+ s_leakProtector = 0;
+ }
+#endif
+ }
+
virtual bool isGeoDataDocument() const { return false; }
virtual bool isGeoSceneDocument() const { return false; }
};
@@ -42,8 +59,28 @@
*/
class GeoNode {
protected:
+#if DUMP_GEONODE_LEAKS > 0
+ GeoNode()
+ {
+ GeoDocument::s_leakProtector++;
+
+#if DUMP_GEONODE_LEAKS > 1
+ fprintf(stderr, "Constructed new GeoNode object, leak protection count: \
%li\n", GeoDocument::s_leakProtector); +#endif
+ }
+
+ virtual ~GeoNode()
+ {
+ --GeoDocument::s_leakProtector;
+
+#if DUMP_GEONODE_LEAKS > 1
+ fprintf(stderr, "Destructed GeoNode object, leak protection 1count: %li\n", \
GeoDocument::s_leakProtector); +#endif
+ }
+#else
GeoNode() { }
virtual ~GeoNode() { }
+#endif
};
#endif // GeoDocument_h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoParser.cpp #784515:784516
@@ -22,11 +22,17 @@
#include <QDebug>
#include "GeoParser.h"
+#include "GeoDocument.h"
#include "GeoTagHandler.h"
// Set to a value greather than 0, to dump parent node chain while parsing
#define DUMP_PARENT_STACK 0
+#if DUMP_GEONODE_LEAKS > 0
+// Initialize here, as there is no GeoDocument.cpp file
+unsigned long GeoDocument::s_leakProtector = 0;
+#endif
+
GeoParser::GeoParser(GeoDataGenericSourceType source)
: QXmlStreamReader()
, m_document(0)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic