Skip to content

Commit

Permalink
use std::unique_ptr for symbol in qgspointcloudlayerchunkloader_p
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem committed Nov 17, 2020
1 parent 7f5656b commit 6235155
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/3d/qgspointcloudlayerchunkloader_p.cpp
Expand Up @@ -96,9 +96,8 @@ void QgsPointCloud3DGeometry::makeVertexBuffer( const QgsPointCloud3DSymbolHandl


QgsPointCloud3DSymbolHandler::QgsPointCloud3DSymbolHandler( QgsPointCloud3DSymbol *symbol )
: mSymbol( symbol )
{

mSymbol.reset( symbol );
}

bool QgsPointCloud3DSymbolHandler::prepare( const Qgs3DRenderContext &context )
Expand Down Expand Up @@ -226,8 +225,7 @@ QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointClou

QgsDebugMsgLevel( QStringLiteral( "loading entity %1" ).arg( node->tileId().text() ), 2 );

QgsPointCloud3DSymbolHandler *handler = new QgsPointCloud3DSymbolHandler( symbol );
mHandler.reset( handler );
mHandler.reset( new QgsPointCloud3DSymbolHandler( symbol ) );

//
// this will be run in a background thread
Expand Down Expand Up @@ -284,8 +282,8 @@ Qt3DCore::QEntity *QgsPointCloudLayerChunkLoader::createEntity( Qt3DCore::QEntit
QgsPointCloudLayerChunkLoaderFactory::QgsPointCloudLayerChunkLoaderFactory( const Qgs3DMapSettings &map, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol )
: mMap( map )
, mPointCloudIndex( pc )
, mSymbol( symbol )
{
mSymbol.reset( symbol );
}

QgsChunkLoader *QgsPointCloudLayerChunkLoaderFactory::createChunkLoader( QgsChunkNode *node ) const
Expand Down
13 changes: 9 additions & 4 deletions src/3d/qgspointcloudlayerchunkloader_p.h
Expand Up @@ -30,14 +30,16 @@
#include "qgschunkloader_p.h"
#include "qgsfeature3dhandler_p.h"
#include "qgschunkedentity_p.h"
#include "qgspointcloud3dsymbol.h"

#define SIP_NO_FILE

class Qgs3DMapSettings;
class QgsPointCloudLayer;
class IndexedPointCloudNode;
class QgsPointCloudIndex;
class QgsPointCloud3DSymbol;

#include <memory>

#include <QFutureWatcher>
#include <Qt3DRender/QGeometry>
Expand Down Expand Up @@ -87,7 +89,7 @@ class QgsPointCloud3DSymbolHandler // : public QgsFeature3DHandler
PointData outNormal; //!< Features that are not selected
// PointData outSelected; //!< Features that are selected

QgsPointCloud3DSymbol *mSymbol = nullptr;
std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
};

class QgsPointCloud3DGeometry: public Qt3DRender::QGeometry
Expand All @@ -114,7 +116,10 @@ class QgsPointCloud3DGeometry: public Qt3DRender::QGeometry
class QgsPointCloudLayerChunkLoaderFactory : public QgsChunkLoaderFactory
{
public:
//! Constructs the factory
/*
* Constructs the factory
* The factory takes ownership over the passed \a symbol
*/
QgsPointCloudLayerChunkLoaderFactory( const Qgs3DMapSettings &map, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol );

//! Creates loader for the given chunk node. Ownership of the returned is passed to the caller.
Expand All @@ -124,7 +129,7 @@ class QgsPointCloudLayerChunkLoaderFactory : public QgsChunkLoaderFactory

const Qgs3DMapSettings &mMap;
QgsPointCloudIndex *mPointCloudIndex;
QgsPointCloud3DSymbol *mSymbol = nullptr;
std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
};


Expand Down

0 comments on commit 6235155

Please sign in to comment.