Skip to content
Permalink
Browse files

use unique_ptrs for tmp pointers

  • Loading branch information
PeterPetrik committed Apr 20, 2018
1 parent 5b8a341 commit 5b1918f5f36441a5df874de1d9ff00af99cee2bb
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/gui/qgsbrowserdockwidget_p.cpp
@@ -19,6 +19,8 @@
***************************************************************************/
#include "qgsbrowserdockwidget_p.h"

#include <memory>

#include <QAbstractTextDocumentLayout>
#include <QHeaderView>
#include <QTreeView>
@@ -143,43 +145,40 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem *item )
{
QgsDebugMsg( "creating raster layer" );
// should copy code from addLayer() to split uri ?
QgsRasterLayer *layer = new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() );
std::unique_ptr<QgsRasterLayer> layer( new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
delete layer;
}
}
else if ( type == QgsMapLayer::MeshLayer )
{
QgsDebugMsg( "creating mesh layer" );
QgsMeshLayer *layer = new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() );
std::unique_ptr<QgsMeshLayer> layer( new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
delete layer;
}
}
else if ( type == QgsMapLayer::VectorLayer )
{
QgsDebugMsg( "creating vector layer" );
QgsVectorLayer *layer = new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() );
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
delete layer;
}
}
else if ( type == QgsMapLayer::PluginLayer )

0 comments on commit 5b1918f

Please sign in to comment.
You can’t perform that action at this time.