Fix clean up of the PUI event handler on reset
This commit is contained in:
parent
c913b752fc
commit
56089b9dd9
2 changed files with 19 additions and 1 deletions
src/Viewer
|
@ -43,6 +43,7 @@
|
||||||
#include <Main/locale.hxx>
|
#include <Main/locale.hxx>
|
||||||
#include <Viewer/CameraGroup.hxx>
|
#include <Viewer/CameraGroup.hxx>
|
||||||
#include <Viewer/FGEventHandler.hxx>
|
#include <Viewer/FGEventHandler.hxx>
|
||||||
|
#include <Viewer/renderer.hxx>
|
||||||
|
|
||||||
#include <Input/input.hxx>
|
#include <Input/input.hxx>
|
||||||
#include <Input/FGMouseInput.hxx>
|
#include <Input/FGMouseInput.hxx>
|
||||||
|
@ -270,6 +271,16 @@ PUICamera::PUICamera() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUICamera::~PUICamera()
|
||||||
|
{
|
||||||
|
SG_LOG(SG_GL, SG_INFO, "Deleting PUI camera");
|
||||||
|
|
||||||
|
auto viewer = globals->get_renderer()->getViewer();
|
||||||
|
if (viewer) {
|
||||||
|
viewer->removeEventHandler(_eventHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PUICamera::init(osg::Group* parent, osgViewer::Viewer* viewer)
|
void PUICamera::init(osg::Group* parent, osgViewer::Viewer* viewer)
|
||||||
{
|
{
|
||||||
setName("PUI FBO camera");
|
setName("PUI FBO camera");
|
||||||
|
@ -339,7 +350,8 @@ void PUICamera::init(osg::Group* parent, osgViewer::Viewer* viewer)
|
||||||
// push_front so we keep the order of event handlers the opposite of
|
// push_front so we keep the order of event handlers the opposite of
|
||||||
// the rendering order (i.e top-most UI layer has the front-most event
|
// the rendering order (i.e top-most UI layer has the front-most event
|
||||||
// handler)
|
// handler)
|
||||||
viewer->getEventHandlers().push_front(new PUIEventHandler(this));
|
_eventHandler = new PUIEventHandler(this);
|
||||||
|
viewer->getEventHandlers().push_front(_eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove once we require OSG 3.4
|
// remove once we require OSG 3.4
|
||||||
|
|
|
@ -30,6 +30,10 @@ namespace osgViewer {
|
||||||
class Viewer;
|
class Viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace osgGA {
|
||||||
|
class GUIEventHandler;
|
||||||
|
}
|
||||||
|
|
||||||
namespace flightgear
|
namespace flightgear
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -39,6 +43,7 @@ public:
|
||||||
static void initPUI();
|
static void initPUI();
|
||||||
|
|
||||||
PUICamera();
|
PUICamera();
|
||||||
|
virtual ~PUICamera();
|
||||||
|
|
||||||
osg::Object* cloneType() const override { return new PUICamera; }
|
osg::Object* cloneType() const override { return new PUICamera; }
|
||||||
osg::Object* clone(const osg::CopyOp&) const override { return new PUICamera; }
|
osg::Object* clone(const osg::CopyOp&) const override { return new PUICamera; }
|
||||||
|
@ -53,6 +58,7 @@ private:
|
||||||
|
|
||||||
osg::Texture2D* _fboTexture = nullptr;
|
osg::Texture2D* _fboTexture = nullptr;
|
||||||
osg::Geometry* _fullScreenQuad = nullptr;
|
osg::Geometry* _fullScreenQuad = nullptr;
|
||||||
|
osgGA::GUIEventHandler* _eventHandler = nullptr;
|
||||||
|
|
||||||
static void puGetWindowSize(int *width, int *height);
|
static void puGetWindowSize(int *width, int *height);
|
||||||
static int puGetWindow();
|
static int puGetWindow();
|
||||||
|
|
Loading…
Add table
Reference in a new issue