Skip to content

Commit 6579c4c

Browse files
committed
Use c++11 '= delete' instead of private copy declarations
Switches the use of private copy constructors/copy assignment operators to instead use public "=delete" declarations. This results in clearer compile-time errors if these deleted functions are used, vs obscure link-time errors.
1 parent 8ebc73b commit 6579c4c

58 files changed

Lines changed: 181 additions & 179 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/analysis/openstreetmap/qgsosmdatabase.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class ANALYSIS_EXPORT QgsOSMDatabase
4949
explicit QgsOSMDatabase( const QString& dbFileName = QString() );
5050
~QgsOSMDatabase();
5151

52+
QgsOSMDatabase( const QgsOSMDatabase& rh ) = delete;
53+
QgsOSMDatabase& operator=( const QgsOSMDatabase& rh ) = delete;
54+
5255
void setFileName( const QString& dbFileName ) { mDbFileName = dbFileName; }
5356
QString filename() const { return mDbFileName; }
5457
bool isOpen() const;
@@ -120,8 +123,6 @@ class ANALYSIS_EXPORT QgsOSMDatabase
120123
sqlite3_stmt* mStmtWayNodePoints;
121124
sqlite3_stmt* mStmtWayTags;
122125

123-
QgsOSMDatabase( const QgsOSMDatabase& rh );
124-
QgsOSMDatabase& operator=( const QgsOSMDatabase& rh );
125126
};
126127

127128

‎src/analysis/raster/qgsalignraster.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class ANALYSIS_EXPORT QgsAlignRaster
4949
RasterInfo( const QString& layerpath );
5050
~RasterInfo();
5151

52+
RasterInfo( const RasterInfo& rh ) = delete;
53+
RasterInfo& operator=( const RasterInfo& rh ) = delete;
54+
5255
//! Check whether the given path is a valid raster
5356
bool isValid() const { return nullptr != mDataset; }
5457

@@ -87,9 +90,6 @@ class ANALYSIS_EXPORT QgsAlignRaster
8790

8891
private:
8992

90-
RasterInfo( const RasterInfo& rh );
91-
RasterInfo& operator=( const RasterInfo& rh );
92-
9393
friend class QgsAlignRaster;
9494
};
9595

‎src/analysis/raster/qgsrastercalcnode.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
7676
QgsRasterCalcNode( const QString& rasterName );
7777
~QgsRasterCalcNode();
7878

79+
QgsRasterCalcNode( const QgsRasterCalcNode& rh ) = delete;
80+
QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh ) = delete;
81+
7982
Type type() const { return mType; }
8083

8184
//set left node
@@ -103,8 +106,6 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
103106
QgsRasterMatrix* mMatrix;
104107
Operator mOperator;
105108

106-
QgsRasterCalcNode( const QgsRasterCalcNode& rh );
107-
QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh );
108109
};
109110

110111

‎src/analysis/raster/qgsrelief.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class ANALYSIS_EXPORT QgsRelief
4545
QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
4646
~QgsRelief();
4747

48+
QgsRelief( const QgsRelief& rh ) = delete;
49+
QgsRelief& operator=( const QgsRelief& rh ) = delete;
50+
4851
/** Starts the calculation, reads from mInputFile and stores the result in mOutputFile
4952
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
5053
@return 0 in case of success*/
@@ -122,8 +125,6 @@ class ANALYSIS_EXPORT QgsRelief
122125
*/
123126
bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
124127

125-
QgsRelief( const QgsRelief& rh );
126-
QgsRelief& operator=( const QgsRelief& rh );
127128
};
128129

129130
#endif // QGSRELIEF_H

‎src/app/nodetool/qgsvertexentry.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class QgsVertexEntry
4343
int penWidth = 2 );
4444
~QgsVertexEntry();
4545

46+
QgsVertexEntry( const QgsVertexEntry& rh ) = delete;
47+
QgsVertexEntry& operator=( const QgsVertexEntry& rh ) = delete;
48+
4649
const QgsPointV2& point() const { return mPoint; }
4750
QgsPoint pointV1() const { return QgsPoint( mPoint.x(), mPoint.y() ); }
4851
QgsVertexId vertexId() const { return mVertexId; }
@@ -52,10 +55,6 @@ class QgsVertexEntry
5255

5356
void setSelected( bool selected = true );
5457

55-
private:
56-
57-
QgsVertexEntry( const QgsVertexEntry& rh );
58-
QgsVertexEntry& operator=( const QgsVertexEntry& rh );
5958
};
6059

6160
#endif

‎src/app/qgisapp.h‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
154154

155155
~QgisApp();
156156

157+
QgisApp( QgisApp const & ) = delete;
158+
QgisApp & operator=( QgisApp const & ) = delete;
159+
157160
/**
158161
* Add a vector layer to the canvas, returns pointer to it
159162
*/
@@ -1509,11 +1512,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
15091512
//! Configure layer tree view according to the user options from QSettings
15101513
void setupLayerTreeViewFromSettings();
15111514

1512-
/// QgisApp aren't copyable
1513-
QgisApp( QgisApp const & );
1514-
/// QgisApp aren't copyable
1515-
QgisApp & operator=( QgisApp const & );
1516-
15171515
void readSettings();
15181516
void writeSettings();
15191517
void createActions();

‎src/app/qgisappinterface.h‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
4545
QgisAppInterface( QgisApp *qgisapp );
4646
~QgisAppInterface();
4747

48+
QgisAppInterface( QgisAppInterface const & ) = delete;
49+
QgisAppInterface & operator=( QgisAppInterface const & ) = delete;
50+
4851
QgsPluginManagerInterface* pluginManagerInterface() override;
4952

5053
QgsLayerTreeView* layerTreeView() override;
@@ -524,12 +527,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
524527

525528
private:
526529

527-
/// QgisInterface aren't copied
528-
QgisAppInterface( QgisAppInterface const & );
529-
530-
/// QgisInterface aren't copied
531-
QgisAppInterface & operator=( QgisAppInterface const & );
532-
533530
//! Pointer to the QgisApp object
534531
QgisApp *qgis;
535532

‎src/app/qgsidentifyresultsdialog.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ class APP_EXPORT QgsIdentifyPlotCurve
110110
QwtPlot* plot, const QString &title = QString(), QColor color = QColor() );
111111
~QgsIdentifyPlotCurve();
112112

113+
QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh ) = delete;
114+
QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh ) = delete;
115+
113116
private:
114117
QwtPlotCurve* mPlotCurve;
115118

116-
QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh );
117-
QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh );
118119
};
119120

120121
class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase

‎src/core/effects/qgspainteffectregistry.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class CORE_EXPORT QgsPaintEffectRegistry
161161
QgsPaintEffectRegistry();
162162
~QgsPaintEffectRegistry();
163163

164+
QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh ) = delete;
165+
QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh ) = delete;
166+
164167
/** Returns the metadata for a specific effect.
165168
* @param name unique string name for paint effect class
166169
* @returns paint effect metadata if found, otherwise nullptr
@@ -212,9 +215,6 @@ class CORE_EXPORT QgsPaintEffectRegistry
212215

213216
private:
214217

215-
QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh );
216-
QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh );
217-
218218
QMap<QString, QgsPaintEffectAbstractMetadata*> mMetadata;
219219
};
220220

‎src/core/gps/qgsgpsconnectionregistry.h‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,20 @@ class CORE_EXPORT QgsGPSConnectionRegistry
3434
{
3535
public:
3636
QgsGPSConnectionRegistry();
37-
3837
~QgsGPSConnectionRegistry();
3938

39+
QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh ) = delete;
40+
QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh ) = delete;
41+
4042
//! Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again
4143
void registerConnection( QgsGPSConnection* c );
4244
//! Unregisters connection. The registry does no longer own the connection
4345
void unregisterConnection( QgsGPSConnection* c );
4446

4547
QList< QgsGPSConnection *> connectionList() const;
4648

47-
4849
private:
4950

50-
QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh );
51-
QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh );
52-
5351
QSet<QgsGPSConnection*> mConnections;
5452
};
5553

0 commit comments

Comments
 (0)