Skip to content
Permalink
Browse files

Swap QScopedPointer to std::unique_ptr

Why?
- no benefits to QScopedPointer over std::unique_ptr
- unlike QScopedPointer, std::unique_ptr has no overhead
over regular pointers
- using standard language features makes it more likely that
compilers can optimise this use and static analysers can
correctly handle code using unique_ptrs
- QScopedPointer has an (IMO) uncertain future (given that
Qt is dropping features which have become part of the c++
standard). Better to port now before wider use of QScopedPointer
in the codebase!
  • Loading branch information
nyalldawson committed Feb 7, 2017
1 parent 9475850 commit aed6c735a6db5c2dbad526ae4d1670e8e6d76fe5
Showing with 680 additions and 659 deletions.
  1. +1 −1 src/app/composer/qgscomposer.cpp
  2. +2 −2 src/app/dwg/qgsdwgimportdialog.cpp
  3. +5 −4 src/app/dwg/qgsdwgimporter.cpp
  4. +5 −5 src/app/qgisapp.cpp
  5. +2 −2 src/app/qgsannotationwidget.cpp
  6. +3 −2 src/app/qgsannotationwidget.h
  7. +6 −6 src/app/qgsapplayertreeviewmenuprovider.cpp
  8. +1 −1 src/app/qgsbookmarks.cpp
  9. +2 −2 src/app/qgsbookmarks.h
  10. +2 −2 src/app/qgsdiagramproperties.cpp
  11. +1 −1 src/app/qgsdiagramproperties.h
  12. +1 −1 src/app/qgsfeatureaction.cpp
  13. +2 −2 src/app/qgslabelingwidget.cpp
  14. +1 −1 src/app/qgslabelingwidget.h
  15. +2 −2 src/app/qgsmaptooladdfeature.cpp
  16. +2 −2 src/app/qgsmaptooloffsetpointsymbol.cpp
  17. +1 −1 src/app/qgsmaptooloffsetpointsymbol.h
  18. +2 −2 src/app/qgsmaptoolrotatepointsymbols.cpp
  19. +2 −1 src/app/qgsmaptoolrotatepointsymbols.h
  20. +1 −1 src/app/qgspointmarkeritem.cpp
  21. +3 −2 src/app/qgspointmarkeritem.h
  22. +2 −2 src/app/qgsprojectproperties.cpp
  23. +2 −2 src/app/qgstextannotationdialog.cpp
  24. +2 −1 src/app/qgstextannotationdialog.h
  25. +2 −2 src/app/qgsvectorlayerproperties.cpp
  26. +2 −2 src/app/qgsvectorlayerproperties.h
  27. +2 −2 src/core/annotations/qgsannotation.cpp
  28. +4 −4 src/core/annotations/qgsannotation.h
  29. +1 −1 src/core/annotations/qgstextannotation.cpp
  30. +1 −1 src/core/annotations/qgstextannotation.h
  31. +4 −4 src/core/composer/qgsatlascomposition.cpp
  32. +1 −1 src/core/composer/qgsatlascomposition.h
  33. +2 −2 src/core/composer/qgscomposerattributetablev2.cpp
  34. +2 −2 src/core/composer/qgscomposerlabel.cpp
  35. +1 −1 src/core/composer/qgscomposerlabel.h
  36. +1 −1 src/core/composer/qgscomposermapgrid.cpp
  37. +1 −1 src/core/composer/qgscomposermapgrid.h
  38. +11 −11 src/core/composer/qgscomposernodesitem.cpp
  39. +1 −1 src/core/composer/qgscomposerpolygon.cpp
  40. +2 −2 src/core/composer/qgscomposerpolygon.h
  41. +1 −1 src/core/composer/qgscomposerpolyline.cpp
  42. +2 −2 src/core/composer/qgscomposerpolyline.h
  43. +13 −13 src/core/dxf/qgsdxfexport.cpp
  44. +4 −4 src/core/geometry/qgsgeometry.cpp
  45. +5 −5 src/core/geometry/qgsgeometryeditutils.cpp
  46. +17 −16 src/core/geometry/qgsinternalgeometryengine.cpp
  47. +4 −4 src/core/layertree/qgslayertreemodel.cpp
  48. +4 −3 src/core/layertree/qgslayertreemodel.h
  49. +9 −9 src/core/layertree/qgslayertreemodellegendnode.cpp
  50. +1 −1 src/core/layertree/qgslayertreemodellegendnode.h
  51. +4 −4 src/core/qgsaggregatecalculator.cpp
  52. +5 −5 src/core/qgsconditionalstyle.cpp
  53. +2 −2 src/core/qgsconditionalstyle.h
  54. +1 −1 src/core/qgsdataitem.cpp
  55. +1 −1 src/core/qgsdataitemproviderregistry.cpp
  56. +5 −5 src/core/qgsdiagramrenderer.cpp
  57. +2 −2 src/core/qgsdiagramrenderer.h
  58. +1 −1 src/core/qgsexpression.cpp
  59. +1 −1 src/core/qgsmaphittest.cpp
  60. +7 −6 src/core/qgsmaptopixelgeometrysimplifier.cpp
  61. +10 −10 src/core/qgspallabeling.cpp
  62. +4 −4 src/core/qgsproject.cpp
  63. +2 −2 src/core/qgsproject.h
  64. +2 −2 src/core/qgsproperty.cpp
  65. +2 −2 src/core/qgspropertytransformer.cpp
  66. +2 −1 src/core/qgspropertytransformer.h
  67. +3 −3 src/core/qgsproviderregistry.cpp
  68. +1 −1 src/core/qgsrendercontext.cpp
  69. +2 −1 src/core/qgsrendercontext.h
  70. +4 −4 src/core/qgstextrenderer.cpp
  71. +2 −2 src/core/qgstransaction.cpp
  72. +1 −1 src/core/qgstransactiongroup.cpp
  73. +2 −1 src/core/qgstransactiongroup.h
  74. +9 −9 src/core/qgsvectorlayer.cpp
  75. +3 −3 src/core/qgsvectorlayerdiagramprovider.cpp
  76. +2 −2 src/core/qgsvectorlayerfeatureiterator.cpp
  77. +2 −1 src/core/qgsvectorlayerfeatureiterator.h
  78. +1 −1 src/core/qgsvectorlayerimport.cpp
  79. +2 −2 src/core/qgsvectorlayerlabelprovider.cpp
  80. +6 −6 src/core/qgsvectorlayerrenderer.cpp
  81. +2 −2 src/core/qgsvectorlayerutils.cpp
  82. +1 −1 src/core/raster/qgscolorrampshader.cpp
  83. +2 −1 src/core/raster/qgscolorrampshader.h
  84. +2 −2 src/core/raster/qgsrasterlayer.cpp
  85. +3 −3 src/core/symbology-ng/qgs25drenderer.cpp
  86. +1 −1 src/core/symbology-ng/qgs25drenderer.h
  87. +3 −3 src/core/symbology-ng/qgsarrowsymbollayer.cpp
  88. +3 −3 src/core/symbology-ng/qgsarrowsymbollayer.h
  89. +19 −19 src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp
  90. +4 −4 src/core/symbology-ng/qgscategorizedsymbolrenderer.h
  91. +1 −1 src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h
  92. +28 −28 src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp
  93. +4 −4 src/core/symbology-ng/qgsgraduatedsymbolrenderer.h
  94. +1 −1 src/core/symbology-ng/qgsheatmaprenderer.cpp
  95. +1 −1 src/core/symbology-ng/qgsheatmaprenderer.h
  96. +3 −3 src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
  97. +1 −1 src/core/symbology-ng/qgsinvertedpolygonrenderer.h
  98. +9 −9 src/core/symbology-ng/qgsmarkersymbollayer.cpp
  99. +1 −1 src/core/symbology-ng/qgsmarkersymbollayer.h
  100. +2 −2 src/core/symbology-ng/qgsnullsymbolrenderer.cpp
  101. +1 −1 src/core/symbology-ng/qgsnullsymbolrenderer.h
  102. +2 −2 src/core/symbology-ng/qgspointclusterrenderer.cpp
  103. +1 −1 src/core/symbology-ng/qgspointclusterrenderer.h
  104. +2 −2 src/core/symbology-ng/qgspointdisplacementrenderer.cpp
  105. +1 −1 src/core/symbology-ng/qgspointdisplacementrenderer.h
  106. +1 −1 src/core/symbology-ng/qgspointdistancerenderer.cpp
  107. +1 −1 src/core/symbology-ng/qgspointdistancerenderer.h
  108. +18 −18 src/core/symbology-ng/qgssinglesymbolrenderer.cpp
  109. +1 −1 src/core/symbology-ng/qgssinglesymbolrenderer.h
  110. +2 −2 src/core/symbology-ng/qgsstyle.cpp
  111. +1 −1 src/gui/qgisgui.cpp
  112. +5 −5 src/gui/qgsadvanceddigitizingdockwidget.cpp
  113. +10 −10 src/gui/qgsadvanceddigitizingdockwidget.h
  114. +12 −12 src/gui/qgscolorrampbutton.cpp
  115. +32 −32 src/gui/qgscomposerview.cpp
  116. +3 −2 src/gui/qgscomposerview.h
  117. +4 −4 src/gui/qgsdatadefinedbutton.cpp
  118. +1 −1 src/gui/qgsdatadefinedbutton.h
  119. +1 −1 src/gui/qgsexpressionlineedit.cpp
  120. +2 −1 src/gui/qgsexpressionlineedit.h
  121. +1 −1 src/gui/qgsformannotation.h
  122. +2 −1 src/gui/qgshelp.cpp
  123. +8 −8 src/gui/qgsmapcanvas.cpp
  124. +2 −2 src/gui/qgsmapcanvas.h
  125. +3 −3 src/gui/qgsmaptoolcapture.cpp
  126. +2 −2 src/gui/qgsrasterformatsaveoptionswidget.cpp
  127. +1 −1 src/gui/qgsvariableeditorwidget.cpp
  128. +3 −2 src/gui/qgsvariableeditorwidget.h
  129. +3 −3 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
  130. +1 −1 src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp
  131. +4 −4 src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp
  132. +3 −3 src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp
  133. +2 −2 src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h
  134. +9 −9 src/gui/symbology-ng/qgssizescalewidget.cpp
  135. +2 −2 src/gui/symbology-ng/qgsstyleexportimportdialog.cpp
  136. +11 −11 src/gui/symbology-ng/qgsstylemanagerdialog.cpp
  137. +1 −1 src/gui/symbology-ng/qgssymbolselectordialog.cpp
  138. +1 −1 src/gui/symbology-ng/qgssymbolselectordialog.h
  139. +1 −1 src/gui/symbology-ng/qgssymbolwidgetcontext.cpp
  140. +2 −1 src/gui/symbology-ng/qgssymbolwidgetcontext.h
  141. +1 −1 src/providers/ows/qgsowsdataitems.cpp
  142. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  143. +2 −1 src/providers/virtual/qgsvirtuallayerfeatureiterator.h
  144. +1 −1 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  145. +2 −2 src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
  146. +7 −7 src/providers/wms/qgswmsprovider.cpp
  147. +1 −1 src/providers/wms/qgswmsprovider.h
  148. +9 −9 src/server/qgswmsconfigparser.cpp
  149. +3 −3 src/server/services/wfs/qgswfsgetfeature.cpp
  150. +2 −2 src/server/services/wms/qgsmaprendererjobproxy.cpp
  151. +1 −1 src/server/services/wms/qgsmaprendererjobproxy.h
  152. +2 −2 src/server/services/wms/qgswmsgetlegendgraphics.cpp
  153. +2 −2 src/server/services/wms/qgswmsgetmap.cpp
  154. +1 −1 src/server/services/wms/qgswmsgetprint.cpp
  155. +22 −22 src/server/services/wms/qgswmsrenderer.cpp
  156. +10 −10 tests/src/app/testqgsattributetable.cpp
  157. +6 −6 tests/src/app/testqgsfieldcalculator.cpp
  158. +36 −36 tests/src/app/testqgsmaptoolidentifyaction.cpp
  159. +6 −6 tests/src/app/testqgsmaptoolselect.cpp
  160. +8 −8 tests/src/app/testqgsmeasuretool.cpp
  161. +2 −2 tests/src/app/testqgsvectorlayersaveasdialog.cpp
  162. +9 −8 tests/src/core/testqgis.cpp
  163. +4 −4 tests/src/core/testqgsdatadefined.cpp
  164. +6 −6 tests/src/core/testqgsexpressioncontext.cpp
  165. +2 −1 tests/src/core/testqgsfield.cpp
  166. +20 −20 tests/src/core/testqgsgeometry.cpp
  167. +2 −2 tests/src/core/testqgsproperty.cpp
  168. +1 −1 tests/src/core/testqgsrasterfilewriter.cpp
  169. +11 −11 tests/src/core/testqgstaskmanager.cpp
  170. +4 −4 tests/src/gui/testqgsfieldexpressionwidget.cpp
@@ -913,7 +913,7 @@ void QgsComposer::setTitle( const QString& title )
bool QgsComposer::loadFromTemplate( const QDomDocument& templateDoc, bool clearExisting )
{
// provide feedback, since composer will be hidden when loading template (much faster)
QScopedPointer< QDialog > dlg( new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ), this ) );
std::unique_ptr< QDialog > dlg( new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ), this ) );
dlg->setStyleSheet( mQgis->styleSheet() );
dlg->show();

@@ -155,7 +155,7 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked()

bool lblVisible = false;

QScopedPointer<QgsVectorLayer> d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
if ( d && d->isValid() )
{
int idxPath = d->fields().lookupField( "path" );
@@ -190,7 +190,7 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked()

lblMessage->setVisible( lblVisible );

QScopedPointer<QgsVectorLayer> l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
if ( l && l->isValid() )
{
int idxName = l->fields().lookupField( "name" );
@@ -44,6 +44,7 @@
#include <cpl_string.h>
#include <gdal.h>
#include <ogr_srs_api.h>
#include <memory>

#define LOG( x ) { QgsDebugMsg( x ); QgsMessageLog::logMessage( x, QObject::tr( "DWG/DXF import" ) ); }
#define ONCE( x ) { static bool show=true; if( show ) LOG( x ); show=false; }
@@ -614,7 +615,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
if ( fi.suffix().toLower() == "dxf" )
{
//loads dxf
QScopedPointer<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
std::unique_ptr<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
if ( !dxf->read( this, false ) )
{
result = DRW::BAD_UNKNOWN;
@@ -623,7 +624,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
else if ( fi.suffix().toLower() == "dwg" )
{
//loads dwg
QScopedPointer<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
std::unique_ptr<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
if ( !dwg->read( this, false ) )
{
result = dwg->getError();
@@ -1185,12 +1186,12 @@ void QgsDwgImporter::addAppId( const DRW_AppId &data )
bool QgsDwgImporter::createFeature( OGRLayerH layer, OGRFeatureH f, const QgsAbstractGeometry &g0 ) const
{
const QgsAbstractGeometry *g;
QScopedPointer<QgsAbstractGeometry> sg( nullptr );
std::unique_ptr<QgsAbstractGeometry> sg( nullptr );

if ( !mUseCurves && g0.hasCurvedSegments() )
{
sg.reset( g0.segmentize() );
g = sg.data();
g = sg.get();
}
else
{
@@ -449,15 +449,15 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex& index )
if ( !originalSymbol )
return;

QScopedPointer< QgsSymbol > symbol( originalSymbol->clone() );
std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() );
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), vlayer, this );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, this );
QgsSymbolWidgetContext context;
context.setMapCanvas( mMapCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
node->setSymbol( symbol.take() );
node->setSymbol( symbol.release() );
}

return;
@@ -6241,7 +6241,7 @@ void QgisApp::saveAsRasterFile()
// TODO: show error dialogs
// TODO: this code should go somewhere else, but probably not into QgsRasterFileWriter
// clone pipe/provider is not really necessary, ready for threads
QScopedPointer<QgsRasterPipe> pipe( nullptr );
std::unique_ptr<QgsRasterPipe> pipe( nullptr );

if ( d.mode() == QgsRasterLayerSaveAsDialog::RawDataMode )
{
@@ -6303,7 +6303,7 @@ void QgisApp::saveAsRasterFile()
fileWriter.setPyramidsFormat( d.pyramidsFormat() );
fileWriter.setPyramidsConfigOptions( d.pyramidsConfigOptions() );

QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe.data(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe.get(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
if ( err != QgsRasterFileWriter::NoError )
{
QMessageBox::warning( this, tr( "Error" ),
@@ -147,7 +147,7 @@ void QgsAnnotationWidget::updateCenterIcon()
{
return;
}
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mMarkerSymbol.data(), mMapMarkerButton->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mMarkerSymbol.get(), mMapMarkerButton->iconSize() );
mMapMarkerButton->setIcon( icon );
}

@@ -157,7 +157,7 @@ void QgsAnnotationWidget::updateFillIcon()
{
return;
}
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mFillSymbol.data(), mFrameStyleButton->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mFillSymbol.get(), mFrameStyleButton->iconSize() );
mFrameStyleButton->setIcon( icon );
}

@@ -20,6 +20,7 @@

#include "ui_qgsannotationwidgetbase.h"
#include "qgis_app.h"
#include <memory>

class QgsMapCanvasAnnotationItem;
class QgsMarkerSymbol;
@@ -47,8 +48,8 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW

private:
QgsMapCanvasAnnotationItem* mItem = nullptr;
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
QScopedPointer< QgsFillSymbol > mFillSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsFillSymbol > mFillSymbol;

void blockAllSignals( bool block );
void updateCenterIcon();
@@ -500,15 +500,15 @@ void QgsAppLayerTreeViewMenuProvider::editVectorSymbol()
if ( !singleRenderer )
return;

QScopedPointer< QgsSymbol > symbol( singleRenderer->symbol() ? singleRenderer->symbol()->clone() : nullptr );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), layer, mView->window() );
std::unique_ptr< QgsSymbol > symbol( singleRenderer->symbol() ? singleRenderer->symbol()->clone() : nullptr );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), layer, mView->window() );
dlg.setWindowTitle( tr( "Symbol selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
singleRenderer->setSymbol( symbol.take() );
singleRenderer->setSymbol( symbol.release() );
layer->triggerRepaint();
mView->refreshLayerSymbology( layer->id() );
}
@@ -576,16 +576,16 @@ void QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol()
if ( !originalSymbol )
return;

QScopedPointer< QgsSymbol > symbol( originalSymbol->clone() );
std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() );
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), vlayer, mView->window() );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, mView->window() );
dlg.setWindowTitle( tr( "Symbol selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
node->setSymbol( symbol.take() );
node->setSymbol( symbol.release() );
if ( vlayer )
{
vlayer->emitStyleChanged();
@@ -101,7 +101,7 @@ QgsBookmarks::QgsBookmarks( QWidget *parent )
mProjectModel = new QgsProjectBookmarksTableModel();
mModel.reset( new QgsMergedBookmarksTableModel( *mQgisModel, *mProjectModel, lstBookmarks ) );

lstBookmarks->setModel( mModel.data() );
lstBookmarks->setModel( mModel.get() );

QSettings settings;
lstBookmarks->header()->restoreState( settings.value( QStringLiteral( "/Windows/Bookmarks/headerstate" ) ).toByteArray() );
@@ -18,7 +18,7 @@
#define QGSBOOKMARKS_H

#include <QSqlTableModel>
#include <QScopedPointer>
#include <memory>

#include "ui_qgsbookmarksbase.h"
#include "qgsdockwidget.h"
@@ -121,7 +121,7 @@ class APP_EXPORT QgsBookmarks : public QgsDockWidget, private Ui::QgsBookmarksBa
private:
QSqlTableModel* mQgisModel;
QgsProjectBookmarksTableModel* mProjectModel;
QScopedPointer<QgsMergedBookmarksTableModel> mModel;
std::unique_ptr<QgsMergedBookmarksTableModel> mModel;

void saveWindowLocation();
void restorePosition();
@@ -251,7 +251,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mCheckBoxAttributeLegend->setChecked( dr->attributeLegend() );
mCheckBoxSizeLegend->setChecked( dr->sizeLegend() );
mSizeLegendSymbol.reset( dr->sizeLegendSymbol() ? dr->sizeLegendSymbol()->clone() : QgsMarkerSymbol::createSimple( QgsStringMap() ) );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.get(), mButtonSizeLegendSymbol->iconSize() );
mButtonSizeLegendSymbol->setIcon( icon );

//assume single category or linearly interpolated diagram renderer for now
@@ -943,7 +943,7 @@ void QgsDiagramProperties::on_mButtonSizeLegendSymbol_clicked()
if ( d.exec() == QDialog::Accepted )
{
mSizeLegendSymbol.reset( newSymbol );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.get(), mButtonSizeLegendSymbol->iconSize() );
mButtonSizeLegendSymbol->setIcon( icon );
}
else
@@ -80,7 +80,7 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr

// Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
QString mDiagramType;
QScopedPointer< QgsMarkerSymbol > mSizeLegendSymbol;
std::unique_ptr< QgsMarkerSymbol > mSizeLegendSymbol;

QString guessLegendText( const QString &expression );
QgsMapCanvas *mMapCanvas;
@@ -116,7 +116,7 @@ bool QgsFeatureAction::editFeature( bool showModal )

if ( showModal )
{
QScopedPointer<QgsAttributeDialog> dialog( newDialog( false ) );
std::unique_ptr<QgsAttributeDialog> dialog( newDialog( false ) );

if ( !mFeature->isValid() )
dialog->setMode( QgsAttributeForm::AddFeatureMode );
@@ -46,13 +46,13 @@ QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canva

void QgsLabelingWidget::resetSettings()
{
if ( mOldSettings.data() )
if ( mOldSettings )
{
if ( mOldSettings->type() == QLatin1String( "simple" ) )
{
mOldPalSettings.writeToLayer( mLayer );
}
mLayer->setLabeling( mOldSettings.take() );
mLayer->setLabeling( mOldSettings.release() );
}
setLayer( mLayer );
}
@@ -65,7 +65,7 @@ class QgsLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsLabelin

QWidget* mWidget;
QgsLabelingGui* mLabelGui;
QScopedPointer< QgsAbstractVectorLayerLabeling > mOldSettings;
std::unique_ptr< QgsAbstractVectorLayerLabeling > mOldSettings;
QgsPalLayerSettings mOldPalSettings;
};

@@ -233,7 +233,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}

//create QgsFeature with wkb representation
QScopedPointer< QgsFeature > f( new QgsFeature( vlayer->fields(), 0 ) );
std::unique_ptr< QgsFeature > f( new QgsFeature( vlayer->fields(), 0 ) );

//does compoundcurve contain circular strings?
//does provider support circular strings?
@@ -288,7 +288,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
f->setValid( true );

if ( addFeature( vlayer, f.data(), false ) )
if ( addFeature( vlayer, f.get(), false ) )
{
//add points to other features to keep topology up-to-date
bool topologicalEditing = QgsProject::instance()->topologicalEditing();
@@ -77,7 +77,7 @@ void QgsMapToolOffsetPointSymbol::canvasPressOnFeature( QgsMapMouseEvent *e, con
{
Q_UNUSED( e );
mClickedFeature = feature;
createPreviewItem( mMarkerSymbol.data() );
createPreviewItem( mMarkerSymbol.get() );
mOffsetItem->setPointLocation( snappedPoint );
updateOffsetPreviewItem( mClickedPoint, mClickedPoint );
mOffsetting = true;
@@ -97,7 +97,7 @@ bool QgsMapToolOffsetPointSymbol::checkSymbolCompatibility( QgsMarkerSymbol* mar
continue;

ok = true;
if ( mMarkerSymbol.isNull() )
if ( !mMarkerSymbol )
{
double symbolRotation = markerSymbol->angle();
if ( layer->dataDefinedProperties().isActive( QgsSymbolLayer::PropertyAngle ) )
@@ -60,7 +60,7 @@ class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol
QgsPointMarkerItem* mOffsetItem;

//! Clone of first found marker symbol for feature with offset attribute set
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;

//! Feature which was clicked on
QgsFeature mClickedFeature;
@@ -83,7 +83,7 @@ void QgsMapToolRotatePointSymbols::canvasPressOnFeature( QgsMapMouseEvent *e, co
}

mCurrentRotationFeature = attrVal.toDouble();
createPixmapItem( mMarkerSymbol.data() );
createPixmapItem( mMarkerSymbol.get() );
if ( mRotationItem )
{
mRotationItem->setPointLocation( snappedPoint );
@@ -101,7 +101,7 @@ bool QgsMapToolRotatePointSymbols::checkSymbolCompatibility( QgsMarkerSymbol* ma
{
mCurrentRotationAttributes << mActiveLayer->fields().indexFromName( ddAngle.field() );
ok = true;
if ( mMarkerSymbol.isNull() )
if ( !mMarkerSymbol )
{
mMarkerSymbol.reset( markerSymbol->clone() );
}
@@ -18,6 +18,7 @@

#include "qgsmaptoolpointsymbol.h"
#include "qgis_app.h"
#include <memory>

class QgsPointRotationItem;
class QgsMarkerSymbol;
@@ -62,7 +63,7 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol
//! True if ctrl was pressed during the last mouse move event
bool mCtrlPressed;
//! Clone of first found marker symbol for feature with rotation attribute set
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;

void drawArrow( double azimut ) const;
//! Calculates the azimut between mousePos and mSnappedPoint
@@ -94,7 +94,7 @@ void QgsPointMarkerItem::setSymbol( QgsMarkerSymbol *symbol )

QgsMarkerSymbol*QgsPointMarkerItem::symbol()
{
return mMarkerSymbol.data();
return mMarkerSymbol.get();
}

void QgsPointMarkerItem::setFeature( const QgsFeature& feature )
@@ -22,6 +22,7 @@
#include <QFontMetricsF>
#include <QPixmap>
#include "qgis_app.h"
#include <memory>

class QgsMarkerSymbol;

@@ -91,9 +92,9 @@ class APP_EXPORT QgsPointMarkerItem: public QgsMapCanvasItem
private:

QgsFeature mFeature;
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
QPointF mLocation;
QScopedPointer< QgsDrawSourceEffect > mOpacityEffect;
std::unique_ptr< QgsDrawSourceEffect > mOpacityEffect;

QgsRenderContext renderContext( QPainter* painter );
};
@@ -1718,8 +1718,8 @@ void QgsProjectProperties::populateStyles()
for ( int i = 0; i < colorRamps.count(); ++i )
{
QString name = colorRamps[i];
QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), cboStyleColorRamp->iconSize() );
std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), cboStyleColorRamp->iconSize() );
cboStyleColorRamp->addItem( icon, name );
}

0 comments on commit aed6c73

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