1
0
Fork 0

Fix leak of FGTerrain on shutdown

This fixes us leaking all STG objects on shutdown, due to an errant
raw pointer in the scenery layer.
This commit is contained in:
James Turner 2020-08-11 11:16:30 +01:00
parent 4743ede3b3
commit e2e5223784
6 changed files with 14 additions and 13 deletions

View file

@ -16,13 +16,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
#include "SceneryPager.hxx"
#include <algorithm>
#include <functional>
#include <simgear/debug/logstream.hxx>
using namespace osg;
using namespace flightgear;
@ -40,6 +39,7 @@ SceneryPager::SceneryPager(const SceneryPager& rhs) :
SceneryPager::~SceneryPager()
{
SG_LOG(SG_TERRAIN, SG_INFO, "Destroying scenery pager");
}
void SceneryPager::clearRequests()

View file

@ -407,12 +407,12 @@ void FGScenery::init() {
if ( engine == "pagedLOD" ) {
#ifdef ENABLE_GDAL
_terrain = new FGPgtTerrain();
_terrain.reset(new FGPgtTerrain);
#else
_terrain = new FGStgTerrain();
_terrain.reset(new FGStgTerrain);
#endif
} else {
_terrain = new FGStgTerrain();
_terrain.reset(new FGStgTerrain);
}
_terrain->init( terrain_branch.get() );
@ -438,6 +438,8 @@ void FGScenery::shutdown()
particles_branch = NULL;
precipitation_branch = NULL;
_terrain.reset();
// Toggle the setup flag.
_inited = false;
}

View file

@ -146,7 +146,7 @@ public:
void materialLibChanged();
private:
// the terrain engine
FGTerrain* _terrain;
std::unique_ptr<FGTerrain> _terrain;
// The state of the scene graph.
bool _inited;

View file

@ -49,8 +49,8 @@ class BVHMaterial;
class FGTerrain
{
public:
FGTerrain() {};
~FGTerrain() {};
FGTerrain() = default;
virtual ~FGTerrain() = default;
// Implementation of SGSubsystem. - called from Scenery
virtual void init ( osg::Group* terrain ) = 0;

View file

@ -21,9 +21,7 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
#include <stdio.h>
#include <string.h>
@ -232,6 +230,7 @@ FGStgTerrain::FGStgTerrain() :
FGStgTerrain::~FGStgTerrain()
{
SG_LOG(SG_TERRAIN, SG_INFO, "FGStgTerrain::dtor");
}

View file

@ -51,7 +51,7 @@ class FGStgTerrain : public FGTerrain
public:
FGStgTerrain();
~FGStgTerrain();
virtual ~FGStgTerrain();
// Implementation of SGSubsystem.
void init ( osg::Group* terrain );