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:
parent
4743ede3b3
commit
e2e5223784
6 changed files with 14 additions and 13 deletions
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class FGStgTerrain : public FGTerrain
|
|||
public:
|
||||
|
||||
FGStgTerrain();
|
||||
~FGStgTerrain();
|
||||
virtual ~FGStgTerrain();
|
||||
|
||||
// Implementation of SGSubsystem.
|
||||
void init ( osg::Group* terrain );
|
||||
|
|
Loading…
Add table
Reference in a new issue