Skip to content

Commit

Permalink
Fix leak of point cloud symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 11, 2020
1 parent 1e086f2 commit eec7c53
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/3d/qgspointcloudlayer3drenderer.cpp
Expand Up @@ -28,9 +28,9 @@

#include "qgis.h"

QgsPointCloud3DRenderContext::QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol )
QgsPointCloud3DRenderContext::QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, std::unique_ptr<QgsPointCloud3DSymbol> symbol )
: Qgs3DRenderContext( map )
, mSymbol( symbol )
, mSymbol( std::move( symbol ) )
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgspointcloudlayer3drenderer.h
Expand Up @@ -44,7 +44,7 @@ class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext
public:

//! Constructor for QgsPointCloud3DRenderContext.
QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol );
QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, std::unique_ptr< QgsPointCloud3DSymbol > symbol );

//! QgsPointCloudRenderContext cannot be copied.
QgsPointCloud3DRenderContext( const QgsPointCloud3DRenderContext &rh ) = delete;
Expand Down
16 changes: 8 additions & 8 deletions src/3d/qgspointcloudlayerchunkloader_p.cpp
Expand Up @@ -46,10 +46,10 @@

///////////////

QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, QgsPointCloud3DSymbol *symbol )
QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr< QgsPointCloud3DSymbol > symbol )
: QgsChunkLoader( node )
, mFactory( factory )
, mContext( factory->mMap, dynamic_cast<QgsPointCloud3DSymbol *>( symbol->clone() ) )
, mContext( factory->mMap, std::move( symbol ) )
{
QgsPointCloudIndex *pc = mFactory->mPointCloudIndex;
mContext.setAttributes( pc->attributes() );
Expand All @@ -61,16 +61,16 @@ QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointClou

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

if ( symbol->symbolType() == QLatin1String( "single-color" ) )
if ( mContext.symbol()->symbolType() == QLatin1String( "single-color" ) )
mHandler.reset( new QgsSingleColorPointCloud3DSymbolHandler() );
else if ( symbol->symbolType() == QLatin1String( "color-ramp" ) )
else if ( mContext.symbol()->symbolType() == QLatin1String( "color-ramp" ) )
mHandler.reset( new QgsColorRampPointCloud3DSymbolHandler() );
else if ( symbol->symbolType() == QLatin1String( "rgb" ) )
else if ( mContext.symbol()->symbolType() == QLatin1String( "rgb" ) )
mHandler.reset( new QgsRGBPointCloud3DSymbolHandler() );
else if ( symbol->symbolType() == QLatin1String( "classification" ) )
else if ( mContext.symbol()->symbolType() == QLatin1String( "classification" ) )
{
mHandler.reset( new QgsClassificationPointCloud3DSymbolHandler() );
QgsClassificationPointCloud3DSymbol *classificationSymbol = dynamic_cast<QgsClassificationPointCloud3DSymbol *>( symbol );
const QgsClassificationPointCloud3DSymbol *classificationSymbol = dynamic_cast<const QgsClassificationPointCloud3DSymbol *>( mContext.symbol() );
mContext.setFilteredOutCategories( classificationSymbol->getFilteredOutCategories() );
}

Expand Down Expand Up @@ -137,7 +137,7 @@ QgsChunkLoader *QgsPointCloudLayerChunkLoaderFactory::createChunkLoader( QgsChun
{
QgsChunkNodeId id = node->tileId();
Q_ASSERT( mPointCloudIndex->hasNode( IndexedPointCloudNode( id.d, id.x, id.y, id.z ) ) );
return new QgsPointCloudLayerChunkLoader( this, node, dynamic_cast<QgsPointCloud3DSymbol *>( mSymbol->clone() ) );
return new QgsPointCloudLayerChunkLoader( this, node, std::unique_ptr< QgsPointCloud3DSymbol >( static_cast< QgsPointCloud3DSymbol * >( mSymbol->clone() ) ) );
}

QgsAABB nodeBoundsToAABB( QgsPointCloudDataBounds nodeBounds, QgsVector3D offset, QgsVector3D scale, const Qgs3DMapSettings &map );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgspointcloudlayerchunkloader_p.h
Expand Up @@ -86,7 +86,7 @@ class QgsPointCloudLayerChunkLoader : public QgsChunkLoader
* Constructs the loader
* QgsPointCloudLayerChunkLoader takes ownership over symbol
*/
QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, QgsPointCloud3DSymbol *symbol );
QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr< QgsPointCloud3DSymbol > symbol );
~QgsPointCloudLayerChunkLoader() override;

virtual void cancel() override;
Expand Down

0 comments on commit eec7c53

Please sign in to comment.