Skip to content

Commit 231f6af

Browse files
committed
Don't return const references to implicitly shared Qt classes
Instead return the inexpensive copies. Should provide extra safety against issues like #14822 (refs #14822)
1 parent ef8a135 commit 231f6af

97 files changed

Lines changed: 172 additions & 222 deletions

File tree

Some content is hidden

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

‎python/analysis/raster/qgsrelief.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class QgsRelief
2626

2727
void clearReliefColors();
2828
void addReliefColorClass( const QgsRelief::ReliefColor& color );
29-
const QList< QgsRelief::ReliefColor >& reliefColors() const;
29+
QList< QgsRelief::ReliefColor > reliefColors() const;
3030
void setReliefColors( const QList< QgsRelief::ReliefColor >& c );
3131

3232
/** Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression

‎python/core/composer/qgsatlascomposition.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public:
145145
* @see setPredefinedScales
146146
* @see QgsComposerMap::atlasScalingMode
147147
*/
148-
const QVector<qreal>& predefinedScales() const;
148+
QVector<qreal> predefinedScales() const;
149149

150150
/** Sets the list of predefined scales for the atlas. This is used
151151
* for maps which are set to the predefined atlas scaling mode.

‎python/core/composer/qgscomposerhtml.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class QgsComposerHtml: QgsComposerMultiFrame
5151
* @see setUrl
5252
* @see contentMode
5353
*/
54-
const QUrl& url() const;
54+
QUrl url() const;
5555

5656
/** Sets the HTML to display in the item when the item is using
5757
* the QgsComposerHtml::ManualHtml mode. Setting the HTML using this function

‎python/core/composer/qgscomposition.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator
235235
double snapGridOffsetY() const;
236236

237237
void setGridPen( const QPen& p );
238-
const QPen& gridPen() const;
238+
QPen gridPen() const;
239239

240240
void setGridStyle( const GridStyle s );
241241
GridStyle gridStyle() const;

‎python/core/layertree/qgslayertreemodel.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class QgsLayerTreeModel : QAbstractItemModel
228228
*/
229229
void refreshScaleBasedLayers( const QModelIndex& index = QModelIndex() );
230230

231-
static const QIcon& iconGroup();
231+
static QIcon iconGroup();
232232

233233
//! Filter nodes from QgsMapLayerLegend according to the current filtering rules
234234
QList<QgsLayerTreeModelLegendNode*> filterLegendNodes( const QList<QgsLayerTreeModelLegendNode*>& nodes );

‎python/core/qgsdataitem.sip‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ class QgsLayerItem : QgsDataItem
308308
virtual QString comments() const;
309309

310310
public:
311-
static const QIcon &iconPoint();
312-
static const QIcon &iconLine();
313-
static const QIcon &iconPolygon();
314-
static const QIcon &iconTable();
315-
static const QIcon &iconRaster();
316-
static const QIcon &iconDefault();
311+
static QIcon iconPoint();
312+
static QIcon iconLine();
313+
static QIcon iconPolygon();
314+
static QIcon iconTable();
315+
static QIcon iconRaster();
316+
static QIcon iconDefault();
317317

318318
virtual QString layerName() const;
319319
};
@@ -331,8 +331,8 @@ class QgsDataCollectionItem : QgsDataItem
331331

332332
void addChild( QgsDataItem *item /Transfer/ );
333333

334-
static const QIcon &iconDir(); // shared icon: open/closed directory
335-
static const QIcon &iconDataCollection(); // default icon for data collection
334+
static QIcon iconDir(); // shared icon: open/closed directory
335+
static QIcon iconDataCollection(); // default icon for data collection
336336
};
337337

338338
/** A directory: contains subdirectories and layers */
@@ -477,7 +477,7 @@ class QgsFavoritesItem : QgsDataCollectionItem
477477
void removeDirectory( QgsDirectoryItem *item );
478478

479479
//! Icon for favorites group
480-
static const QIcon &iconFavorites();
480+
static QIcon iconFavorites();
481481
};
482482

483483
/** A zip file: contains layers, using GDAL/OGR VSIFILE mechanism */
@@ -492,7 +492,7 @@ class QgsZipItem : QgsDataCollectionItem
492492
~QgsZipItem();
493493

494494
QVector<QgsDataItem*> createChildren();
495-
const QStringList & getZipFileList();
495+
QStringList getZipFileList();
496496

497497
//! @note not available via python bindings
498498
// static QVector<dataItem_t *> mDataItemPtr;
@@ -504,6 +504,6 @@ class QgsZipItem : QgsDataCollectionItem
504504
//! @note available in python as itemFromFilePath
505505
static QgsDataItem* itemFromPath( QgsDataItem* parent, const QString& filePath, const QString& name, const QString& path ) /Factory,PyName=itemFromFilePath/;
506506

507-
static const QIcon &iconZip();
507+
static QIcon iconZip();
508508

509509
};

‎python/core/qgsexpressionfieldbuffer.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ class QgsExpressionFieldBuffer
6464
*/
6565
void updateFields( QgsFields& flds );
6666

67-
const QList<QgsExpressionFieldBuffer::ExpressionField>& expressions() const;
67+
QList<QgsExpressionFieldBuffer::ExpressionField> expressions() const;
6868
};

‎python/core/qgsnetworkaccessmanager.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class QgsNetworkAccessManager : QNetworkAccessManager
4646
const QNetworkProxy &fallbackProxy() const;
4747

4848
//! retrieve exclude list (urls shouldn't use the fallback proxy)
49-
const QStringList &excludeList() const;
49+
QStringList excludeList() const;
5050

5151
//! set fallback proxy and URL that shouldn't use it.
5252
void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );

‎python/core/qgsproviderregistry.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QgsProviderRegistry
2929
QString pluginList( bool asHtml = false ) const;
3030

3131
/** Return library directory where plugins are found */
32-
const QDir & libraryDirectory() const;
32+
QDir libraryDirectory() const;
3333

3434
/** Set library directory where to search for plugins */
3535
void setLibraryDirectory( const QDir & path );

‎python/core/qgsrelationmanager.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class QgsRelationManager : QObject
2525
*
2626
* @return A QMap where the key is the relation id, the value the relation object.
2727
*/
28-
const QMap<QString, QgsRelation>& relations() const;
28+
QMap<QString, QgsRelation> relations() const;
2929

3030
/**
3131
* Add a relation.

0 commit comments

Comments
 (0)