From 1ccaf3a0bd494085b656279082c4576f302002c7 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 6 May 2009 06:32:09 +0000 Subject: [PATCH 1/4] fix leaks --- simgear/io/tcp_server.cxx | 6 ++++++ simgear/screen/screen-dump.cxx | 1 + simgear/timing/sg_time.cxx | 6 +----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/simgear/io/tcp_server.cxx b/simgear/io/tcp_server.cxx index 01c949da..f0f27866 100644 --- a/simgear/io/tcp_server.cxx +++ b/simgear/io/tcp_server.cxx @@ -12,6 +12,7 @@ class TcpServer { public: TcpServer(); + ~TcpServer(); bool open(); bool process(); bool close(); @@ -25,6 +26,11 @@ TcpServer::TcpServer() channel = new SGSocket( "", "5500", "tcp" ); } +TcpServer::~Tcpserver() +{ + delete channel; +} + bool TcpServer::open() { diff --git a/simgear/screen/screen-dump.cxx b/simgear/screen/screen-dump.cxx index b74f06c0..dc5ba7bd 100644 --- a/simgear/screen/screen-dump.cxx +++ b/simgear/screen/screen-dump.cxx @@ -55,6 +55,7 @@ bool sg_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int ibuffer = (unsigned char *) malloc(win_width*win_height*RGB3); if ( (fp = fopen(filename, "wb")) == NULL ) { + free(ibuffer); printf("Warning: cannot open %s\n", filename); return false; } diff --git a/simgear/timing/sg_time.cxx b/simgear/timing/sg_time.cxx index 66f4b16e..45fd41c1 100644 --- a/simgear/timing/sg_time.cxx +++ b/simgear/timing/sg_time.cxx @@ -122,11 +122,7 @@ SGTime::SGTime() { SGTime::~SGTime() { - if ( tzContainer != NULL ) { - SGTimeZoneContainer *tmp = tzContainer; - tzContainer = NULL; - delete tmp; - } + delete tzContainer; } From bc19609147448bc73c7544edd71bb286f497ea08 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 6 May 2009 16:17:05 +0000 Subject: [PATCH 2/4] tcpserver: typo --- simgear/io/tcp_server.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simgear/io/tcp_server.cxx b/simgear/io/tcp_server.cxx index f0f27866..672e6d96 100644 --- a/simgear/io/tcp_server.cxx +++ b/simgear/io/tcp_server.cxx @@ -26,7 +26,7 @@ TcpServer::TcpServer() channel = new SGSocket( "", "5500", "tcp" ); } -TcpServer::~Tcpserver() +TcpServer::~TcpServer() { delete channel; } From f91d96b51af697a36a3ddbc55257b0954bd3b202 Mon Sep 17 00:00:00 2001 From: mfranz Date: Tue, 12 May 2009 15:56:30 +0000 Subject: [PATCH 3/4] - fix one broken #include path (in a not usually compiled test app) - turn four #include paths from the "foo" form to The quotes form is normally only used for headers with path relative to the including file's path, though the standard doesn't strictly mandate this. This is consistent with the rest of sg, it makes the code's intent clearer and helps to find headers. (And it's a few milliseconds faster, too.) --- simgear/debug/logtest.cxx | 2 +- simgear/math/interpolater.hxx | 2 +- simgear/misc/tabbed_values.cxx | 2 +- simgear/threads/SGThread.cxx | 2 +- simgear/xml/xmldef.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/simgear/debug/logtest.cxx b/simgear/debug/logtest.cxx index afa5ddcc..07a6501a 100644 --- a/simgear/debug/logtest.cxx +++ b/simgear/debug/logtest.cxx @@ -1,5 +1,5 @@ #include -#include "Debug/logstream.hxx" +#include class Test { diff --git a/simgear/math/interpolater.hxx b/simgear/math/interpolater.hxx index 0df566a9..393e39ff 100644 --- a/simgear/math/interpolater.hxx +++ b/simgear/math/interpolater.hxx @@ -35,7 +35,7 @@ #include -#include "simgear/structure/SGReferenced.hxx" +#include #include diff --git a/simgear/misc/tabbed_values.cxx b/simgear/misc/tabbed_values.cxx index dc4d34bc..07ed2063 100644 --- a/simgear/misc/tabbed_values.cxx +++ b/simgear/misc/tabbed_values.cxx @@ -21,10 +21,10 @@ // $Id$ #include +#include #include "tabbed_values.hxx" -#include "assert.h" SGTabbedValues::SGTabbedValues(const char *line) : _line(line) diff --git a/simgear/threads/SGThread.cxx b/simgear/threads/SGThread.cxx index d786c24a..c7a841b0 100644 --- a/simgear/threads/SGThread.cxx +++ b/simgear/threads/SGThread.cxx @@ -11,7 +11,7 @@ # include #endif #if _MSC_VER >= 1300 -# include "winsock2.h" +# include #endif #include "SGThread.hxx" diff --git a/simgear/xml/xmldef.h b/simgear/xml/xmldef.h index 49ce9ed6..81de339b 100644 --- a/simgear/xml/xmldef.h +++ b/simgear/xml/xmldef.h @@ -53,7 +53,7 @@ particular environments. */ #ifdef MOZILLA -#include "nspr.h" +#include #define malloc(x) PR_Malloc(x) #define realloc(x, y) PR_Realloc((x), (y)) #define calloc(x, y) PR_Calloc((x),(y)) From 7dc9eba2d0e98d9f08c7000b9424d28998755211 Mon Sep 17 00:00:00 2001 From: frohlich Date: Sat, 16 May 2009 08:13:52 +0000 Subject: [PATCH 4/4] Make SimGear compile with osg trunk Modified Files: simgear/scene/model/SGPagedLOD.cxx simgear/scene/model/SGPagedLOD.hxx simgear/scene/sky/cloud.cxx simgear/scene/sky/moon.cxx simgear/structure/OSGVersion.hxx --- simgear/scene/model/SGPagedLOD.cxx | 2 -- simgear/scene/model/SGPagedLOD.hxx | 16 +++++++++++----- simgear/scene/sky/cloud.cxx | 4 ++++ simgear/scene/sky/moon.cxx | 4 ++++ simgear/structure/OSGVersion.hxx | 24 ++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/simgear/scene/model/SGPagedLOD.cxx b/simgear/scene/model/SGPagedLOD.cxx index fee5dee4..b45af204 100644 --- a/simgear/scene/model/SGPagedLOD.cxx +++ b/simgear/scene/model/SGPagedLOD.cxx @@ -75,9 +75,7 @@ void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp) setTimeStamp(childNum, 0); double priority=1.0; dbp->requestNodeFile(getFileName(childNum),this,priority,0, -#if SG_OSG_VERSION >= 25001 getDatabaseRequest(childNum), -#endif _readerWriterOptions.get()); } diff --git a/simgear/scene/model/SGPagedLOD.hxx b/simgear/scene/model/SGPagedLOD.hxx index 40e59ae7..7bf54266 100644 --- a/simgear/scene/model/SGPagedLOD.hxx +++ b/simgear/scene/model/SGPagedLOD.hxx @@ -17,7 +17,11 @@ #ifndef SGPAGEDLOD_HXX #define SGPAGEDLOD_HXX 1 +#include #include +#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) +#include +#endif #include #include @@ -44,19 +48,21 @@ public: // reimplemented to notify the loading through ModelData bool addChild(osg::Node *child); - void setReaderWriterOptions(osgDB::ReaderWriter::Options *o) { - _readerWriterOptions=o; - _readerWriterOptions->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE); + void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) { + _readerWriterOptions = options; + options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE); +#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) + setDatabaseOptions(options); +#endif } - osgDB::ReaderWriter::Options * getReaderWriterOptions() { + osgDB::ReaderWriter::Options* getReaderWriterOptions() { return _readerWriterOptions.get(); } protected: virtual ~SGPagedLOD(); osg::ref_ptr _readerWriterOptions; - SGPropertyNode_ptr _props; }; } #endif diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index da61f7fc..0addf208 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -43,6 +44,9 @@ #include #include #include +#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) +#include +#endif #include #include diff --git a/simgear/scene/sky/moon.cxx b/simgear/scene/sky/moon.cxx index 7ad47bba..20e1f2b0 100644 --- a/simgear/scene/sky/moon.cxx +++ b/simgear/scene/sky/moon.cxx @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,9 @@ #include #include #include +#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) +#include +#endif #include #include diff --git a/simgear/structure/OSGVersion.hxx b/simgear/structure/OSGVersion.hxx index e8dd8e26..46d0187e 100644 --- a/simgear/structure/OSGVersion.hxx +++ b/simgear/structure/OSGVersion.hxx @@ -23,4 +23,28 @@ #define SG_OSG_VERSION \ ((OPENSCENEGRAPH_MAJOR_VERSION*10000)\ + (OPENSCENEGRAPH_MINOR_VERSION*1000) + OPENSCENEGRAPH_PATCH_VERSION) + +#define SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH) \ + ((OPENSCENEGRAPH_MAJOR_VERSION > (MAJOR)) || \ + (OPENSCENEGRAPH_MAJOR_VERSION == (MAJOR) && \ + (OPENSCENEGRAPH_MINOR_VERSION > (MINOR) || \ + (OPENSCENEGRAPH_MINOR_VERSION == (MINOR) && \ + OPENSCENEGRAPH_PATCH_VERSION >= (PATCH))))) + +#define SG_OSG_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) \ + ((OPENSCENEGRAPH_MAJOR_VERSION > (MAJOR)) || \ + (OPENSCENEGRAPH_MAJOR_VERSION == (MAJOR) && \ + (OPENSCENEGRAPH_MINOR_VERSION > (MINOR) || \ + (OPENSCENEGRAPH_MINOR_VERSION == (MINOR) && \ + OPENSCENEGRAPH_PATCH_VERSION > (PATCH))))) + +#define SG_OSG_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) \ + (!SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH)) + +#define SG_OSG_VERSION_LESS_EQUAL(MAJOR, MINOR, PATCH) \ + (!SG_OSG_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH)) + +#define SG_OSG_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) \ + SG_OSG_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH) + #endif