diff --git a/src/GUI/QQuickDrawable.cxx b/src/GUI/QQuickDrawable.cxx index 36b8468e2..0b26e90e5 100755 --- a/src/GUI/QQuickDrawable.cxx +++ b/src/GUI/QQuickDrawable.cxx @@ -468,6 +468,12 @@ QQuickDrawable::QQuickDrawable() : d(new QQuickDrawablePrivate) } } +QQuickDrawable::~QQuickDrawable() +{ + delete d->qmlEngine; + delete d->renderControl; +} + void QQuickDrawable::setup(osgViewer::GraphicsWindow *gw, osgViewer::Viewer *viewer) { osg::GraphicsContext* gc = gw; @@ -514,12 +520,12 @@ void QQuickDrawable::setup(osgViewer::GraphicsWindow *gw, osgViewer::Viewer *vie d->renderControl->prepareThread(op->thread()); #endif QObject::connect(d->renderControl, &QQuickRenderControl::sceneChanged, - d, &QQuickDrawablePrivate::onSceneChanged); + d.get(), &QQuickDrawablePrivate::onSceneChanged); QObject::connect(d->renderControl, &QQuickRenderControl::renderRequested, - d, &QQuickDrawablePrivate::onRenderRequested); + d.get(), &QQuickDrawablePrivate::onRenderRequested); - viewer->getEventHandlers().push_front(new QuickEventHandler(d)); + viewer->getEventHandlers().push_front(new QuickEventHandler(d.get())); } void QQuickDrawable::drawImplementation(osg::RenderInfo& renderInfo) const @@ -557,7 +563,7 @@ void QQuickDrawable::setSource(QUrl url) d->qmlComponent = new QQmlComponent(d->qmlEngine, url); if (d->qmlComponent->isLoading()) { QObject::connect(d->qmlComponent, &QQmlComponent::statusChanged, - d, &QQuickDrawablePrivate::onComponentLoaded); + d.get(), &QQuickDrawablePrivate::onComponentLoaded); } else { d->onComponentLoaded(); } diff --git a/src/GUI/QQuickDrawable.hxx b/src/GUI/QQuickDrawable.hxx index c3b4fc94e..cad2fda4d 100755 --- a/src/GUI/QQuickDrawable.hxx +++ b/src/GUI/QQuickDrawable.hxx @@ -19,6 +19,7 @@ #ifndef FG_VIEWER_QUICK_DRAWABLE_HXX #define FG_VIEWER_QUICK_DRAWABLE_HXX +#include #include #include @@ -50,7 +51,7 @@ public: void resize(int width, int height); private: - QQuickDrawablePrivate* d; + std::unique_ptr d; }; #endif