|
19 | 19 | ***************************************************************************/
|
20 | 20 | #include "qgsbrowserdockwidget_p.h"
|
21 | 21 |
|
| 22 | +#include <memory> |
| 23 | + |
22 | 24 | #include <QAbstractTextDocumentLayout>
|
23 | 25 | #include <QHeaderView>
|
24 | 26 | #include <QTreeView>
|
@@ -143,43 +145,40 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem *item )
|
143 | 145 | {
|
144 | 146 | QgsDebugMsg( "creating raster layer" );
|
145 | 147 | // should copy code from addLayer() to split uri ?
|
146 |
| - QgsRasterLayer *layer = new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ); |
| 148 | + std::unique_ptr<QgsRasterLayer> layer( new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) ); |
147 | 149 | if ( layer )
|
148 | 150 | {
|
149 | 151 | if ( layer->isValid() )
|
150 | 152 | {
|
151 | 153 | layerCrs = layer->crs();
|
152 | 154 | layerMetadata = layer->htmlMetadata();
|
153 | 155 | }
|
154 |
| - delete layer; |
155 | 156 | }
|
156 | 157 | }
|
157 | 158 | else if ( type == QgsMapLayer::MeshLayer )
|
158 | 159 | {
|
159 | 160 | QgsDebugMsg( "creating mesh layer" );
|
160 |
| - QgsMeshLayer *layer = new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ); |
| 161 | + std::unique_ptr<QgsMeshLayer> layer( new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) ); |
161 | 162 | if ( layer )
|
162 | 163 | {
|
163 | 164 | if ( layer->isValid() )
|
164 | 165 | {
|
165 | 166 | layerCrs = layer->crs();
|
166 | 167 | layerMetadata = layer->htmlMetadata();
|
167 | 168 | }
|
168 |
| - delete layer; |
169 | 169 | }
|
170 | 170 | }
|
171 | 171 | else if ( type == QgsMapLayer::VectorLayer )
|
172 | 172 | {
|
173 | 173 | QgsDebugMsg( "creating vector layer" );
|
174 |
| - QgsVectorLayer *layer = new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ); |
| 174 | + std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) ); |
175 | 175 | if ( layer )
|
176 | 176 | {
|
177 | 177 | if ( layer->isValid() )
|
178 | 178 | {
|
179 | 179 | layerCrs = layer->crs();
|
180 | 180 | layerMetadata = layer->htmlMetadata();
|
181 | 181 | }
|
182 |
| - delete layer; |
183 | 182 | }
|
184 | 183 | }
|
185 | 184 | else if ( type == QgsMapLayer::PluginLayer )
|
|
0 commit comments