Skip to content
Permalink
Browse files

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)
  • Loading branch information
nyalldawson committed Jan 14, 2017
1 parent ef8a135 commit 231f6af0e112ed001acf3ac6a2db1e92b0ccb0b0
Showing with 172 additions and 222 deletions.
  1. +1 −1 python/analysis/raster/qgsrelief.sip
  2. +1 −1 python/core/composer/qgsatlascomposition.sip
  3. +1 −1 python/core/composer/qgscomposerhtml.sip
  4. +1 −1 python/core/composer/qgscomposition.sip
  5. +1 −1 python/core/layertree/qgslayertreemodel.sip
  6. +11 −11 python/core/qgsdataitem.sip
  7. +1 −1 python/core/qgsexpressionfieldbuffer.sip
  8. +1 −1 python/core/qgsnetworkaccessmanager.sip
  9. +1 −1 python/core/qgsproviderregistry.sip
  10. +1 −1 python/core/qgsrelationmanager.sip
  11. +1 −1 python/core/qgsvectordataprovider.sip
  12. +2 −2 python/core/qgsvectorlayer.sip
  13. +3 −3 python/core/symbology-ng/qgssvgcache.sip
  14. +1 −1 python/gui/editorwidgets/core/qgseditorwidgetregistry.sip
  15. +1 −1 python/gui/qgsadvanceddigitizingdockwidget.sip
  16. +4 −4 python/server/qgsserverprojectparser.sip
  17. +2 −2 python/server/qgswmsconfigparser.sip
  18. +2 −2 python/server/qgswmsprojectparser.sip
  19. +1 −1 src/analysis/interpolation/qgsinterpolator.h
  20. +1 −1 src/analysis/raster/qgsrelief.h
  21. +1 −1 src/app/composer/qgscomposer.h
  22. +1 −1 src/app/qgsmeasuretool.cpp
  23. +1 −1 src/app/qgsmeasuretool.h
  24. +1 −1 src/core/auth/qgsauthmethodregistry.cpp
  25. +1 −1 src/core/auth/qgsauthmethodregistry.h
  26. +1 −1 src/core/composer/qgsatlascomposition.h
  27. +1 −1 src/core/composer/qgscomposerhtml.h
  28. +1 −1 src/core/composer/qgscomposition.h
  29. +2 −7 src/core/layertree/qgslayertreemodel.cpp
  30. +1 −1 src/core/layertree/qgslayertreemodel.h
  31. +1 −1 src/core/layertree/qgslayertreemodellegendnode.cpp
  32. +1 −1 src/core/layertree/qgslayertreemodellegendnode.h
  33. +1 −1 src/core/layertree/qgslayertreenode.h
  34. +20 −65 src/core/qgsdataitem.cpp
  35. +11 −11 src/core/qgsdataitem.h
  36. +1 −1 src/core/qgsexpressionfieldbuffer.h
  37. +2 −2 src/core/qgsgml.h
  38. +1 −1 src/core/qgsnetworkaccessmanager.cpp
  39. +1 −1 src/core/qgsnetworkaccessmanager.h
  40. +2 −2 src/core/qgsogcutils.h
  41. +1 −1 src/core/qgsproviderregistry.cpp
  42. +1 −1 src/core/qgsproviderregistry.h
  43. +1 −1 src/core/qgsrelationmanager.cpp
  44. +1 −1 src/core/qgsrelationmanager.h
  45. +1 −1 src/core/qgsvectordataprovider.cpp
  46. +1 −1 src/core/qgsvectordataprovider.h
  47. +2 −2 src/core/qgsvectorlayer.h
  48. +6 −6 src/core/symbology-ng/qgssvgcache.cpp
  49. +6 −6 src/core/symbology-ng/qgssvgcache.h
  50. +1 −1 src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
  51. +1 −1 src/gui/editorwidgets/core/qgseditorwidgetregistry.h
  52. +1 −1 src/gui/qgsadvanceddigitizingdockwidget.h
  53. +1 −1 src/gui/qgscolorschemelist.cpp
  54. +1 −1 src/gui/qgscolorschemelist.h
  55. +1 −1 src/gui/qgscolorswatchgrid.cpp
  56. +1 −1 src/gui/qgscolorswatchgrid.h
  57. +1 −1 src/gui/qgsgradientstopeditor.cpp
  58. +1 −1 src/gui/qgsgradientstopeditor.h
  59. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp
  60. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryanglecheck.h
  61. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp
  62. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryareacheck.h
  63. +3 −3 src/plugins/geometry_checker/checks/qgsgeometrycheck.h
  64. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp
  65. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.h
  66. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp
  67. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.h
  68. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp
  69. +2 −2 src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h
  70. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp
  71. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.h
  72. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp
  73. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrygapcheck.h
  74. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp
  75. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryholecheck.h
  76. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp
  77. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.h
  78. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp
  79. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h
  80. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp
  81. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.h
  82. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp
  83. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.h
  84. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp
  85. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrytypecheck.h
  86. +1 −1 src/plugins/geometry_checker/qgsgeometrychecker.h
  87. +1 −1 src/plugins/gps_importer/qgsbabelformat.cpp
  88. +1 −1 src/plugins/gps_importer/qgsbabelformat.h
  89. +1 −1 src/providers/arcgisrest/qgsamsprovider.h
  90. +2 −2 src/providers/wfs/qgswfsrequest.h
  91. +2 −2 src/server/qgsbufferserverresponse.h
  92. +5 −5 src/server/qgsserverprojectparser.h
  93. +2 −2 src/server/qgssldconfigparser.cpp
  94. +2 −2 src/server/qgssldconfigparser.h
  95. +2 −2 src/server/qgswmsconfigparser.h
  96. +2 −2 src/server/qgswmsprojectparser.cpp
  97. +2 −2 src/server/qgswmsprojectparser.h
@@ -26,7 +26,7 @@ class QgsRelief

void clearReliefColors();
void addReliefColorClass( const QgsRelief::ReliefColor& color );
const QList< QgsRelief::ReliefColor >& reliefColors() const;
QList< QgsRelief::ReliefColor > reliefColors() const;
void setReliefColors( const QList< QgsRelief::ReliefColor >& c );

/** Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression
@@ -145,7 +145,7 @@ public:
* @see setPredefinedScales
* @see QgsComposerMap::atlasScalingMode
*/
const QVector<qreal>& predefinedScales() const;
QVector<qreal> predefinedScales() const;

/** Sets the list of predefined scales for the atlas. This is used
* for maps which are set to the predefined atlas scaling mode.
@@ -51,7 +51,7 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @see setUrl
* @see contentMode
*/
const QUrl& url() const;
QUrl url() const;

/** Sets the HTML to display in the item when the item is using
* the QgsComposerHtml::ManualHtml mode. Setting the HTML using this function
@@ -235,7 +235,7 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator
double snapGridOffsetY() const;

void setGridPen( const QPen& p );
const QPen& gridPen() const;
QPen gridPen() const;

void setGridStyle( const GridStyle s );
GridStyle gridStyle() const;
@@ -228,7 +228,7 @@ class QgsLayerTreeModel : QAbstractItemModel
*/
void refreshScaleBasedLayers( const QModelIndex& index = QModelIndex() );

static const QIcon& iconGroup();
static QIcon iconGroup();

//! Filter nodes from QgsMapLayerLegend according to the current filtering rules
QList<QgsLayerTreeModelLegendNode*> filterLegendNodes( const QList<QgsLayerTreeModelLegendNode*>& nodes );
@@ -308,12 +308,12 @@ class QgsLayerItem : QgsDataItem
virtual QString comments() const;

public:
static const QIcon &iconPoint();
static const QIcon &iconLine();
static const QIcon &iconPolygon();
static const QIcon &iconTable();
static const QIcon &iconRaster();
static const QIcon &iconDefault();
static QIcon iconPoint();
static QIcon iconLine();
static QIcon iconPolygon();
static QIcon iconTable();
static QIcon iconRaster();
static QIcon iconDefault();

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

void addChild( QgsDataItem *item /Transfer/ );

static const QIcon &iconDir(); // shared icon: open/closed directory
static const QIcon &iconDataCollection(); // default icon for data collection
static QIcon iconDir(); // shared icon: open/closed directory
static QIcon iconDataCollection(); // default icon for data collection
};

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

//! Icon for favorites group
static const QIcon &iconFavorites();
static QIcon iconFavorites();
};

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

QVector<QgsDataItem*> createChildren();
const QStringList & getZipFileList();
QStringList getZipFileList();

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

static const QIcon &iconZip();
static QIcon iconZip();

};
@@ -64,5 +64,5 @@ class QgsExpressionFieldBuffer
*/
void updateFields( QgsFields& flds );

const QList<QgsExpressionFieldBuffer::ExpressionField>& expressions() const;
QList<QgsExpressionFieldBuffer::ExpressionField> expressions() const;
};
@@ -46,7 +46,7 @@ class QgsNetworkAccessManager : QNetworkAccessManager
const QNetworkProxy &fallbackProxy() const;

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

//! set fallback proxy and URL that shouldn't use it.
void setFallbackProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
@@ -29,7 +29,7 @@ class QgsProviderRegistry
QString pluginList( bool asHtml = false ) const;

/** Return library directory where plugins are found */
const QDir & libraryDirectory() const;
QDir libraryDirectory() const;

/** Set library directory where to search for plugins */
void setLibraryDirectory( const QDir & path );
@@ -25,7 +25,7 @@ class QgsRelationManager : QObject
*
* @return A QMap where the key is the relation id, the value the relation object.
*/
const QMap<QString, QgsRelation>& relations() const;
QMap<QString, QgsRelation> relations() const;

/**
* Add a relation.
@@ -375,7 +375,7 @@ class QgsVectorDataProvider : QgsDataProvider
/**
* Returns the names of the supported types
*/
const QList< QgsVectorDataProvider::NativeType > &nativeTypes() const;
QList< QgsVectorDataProvider::NativeType > nativeTypes() const;

/**
* Returns true if the provider is strict about the type of inserted features
@@ -1111,10 +1111,10 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator

const QMap< QString, QString >& attributeAliases() const;

const QSet<QString>& excludeAttributesWms() const;
QSet<QString> excludeAttributesWms() const;
void setExcludeAttributesWms( const QSet<QString>& att );

const QSet<QString>& excludeAttributesWfs() const;
QSet<QString> excludeAttributesWfs() const;
void setExcludeAttributesWfs( const QSet<QString>& att );

/** Delete an attribute field (but does not commit it) */
@@ -79,7 +79,7 @@ class QgsSvgCache : QObject
* @param rasterScaleFactor raster scale factor
* @param fitsInCache
*/
const QImage& svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
QImage svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache );
/** Get SVG as QPicture&.
* @param file Absolute or relative path to SVG file.
@@ -91,7 +91,7 @@ class QgsSvgCache : QObject
* @param rasterScaleFactor raster scale factor
* @param forceVectorOutput
*/
const QPicture& svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
QPicture svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput = false );

/** Calculates the viewbox size of a (possibly cached) SVG file.
@@ -144,7 +144,7 @@ class QgsSvgCache : QObject
QByteArray getImageData( const QString &path ) const;

/** Get SVG content*/
const QByteArray& svgContent( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
QByteArray svgContent( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor );

signals:
@@ -110,7 +110,7 @@ class QgsEditorWidgetRegistry : QObject
*
* @return All ids and factories
*/
const QMap<QString, QgsEditorWidgetFactory*>& factories();
QMap<QString, QgsEditorWidgetFactory*> factories();

/**
* Get a factory for the given widget type id.
@@ -269,7 +269,7 @@ class QgsAdvancedDigitizingDockWidget : QDockWidget
/**
* Snapped to a segment
*/
const QList<QgsPoint>& snappedSegment() const;
QList<QgsPoint> snappedSegment() const;

//! return the action used to enable/disable the tools
QAction* enableAction();
@@ -60,9 +60,9 @@ class QgsServerProjectParser

QStringList supportedOutputCrsList() const;

const QList<QDomElement>& projectLayerElements() const;
QList<QDomElement> projectLayerElements() const;

const QList<QDomElement>& legendGroupElements() const;
QList<QDomElement> legendGroupElements() const;

QString projectTitle() const;

@@ -73,8 +73,8 @@ class QgsServerProjectParser
const QSet<QString>& restrictedLayers() const;
bool useLayerIds() const;

const QHash< QString, QDomElement >& projectLayerElementsByName() const;
const QHash< QString, QDomElement >& projectLayerElementsById() const;
QHash< QString, QDomElement > projectLayerElementsByName() const;
QHash< QString, QDomElement > projectLayerElementsById() const;

// SIP doesn't like QMap:
// void layerFromLegendLayer( const QDomElement& legendLayerElem, QMap< int, QgsMapLayer*>& layers, bool useCache = true ) const;
@@ -88,8 +88,8 @@ class QgsWmsConfigParser
virtual double legendIconLabelSpace() const = 0;
virtual double legendSymbolWidth() const = 0;
virtual double legendSymbolHeight() const = 0;
virtual const QFont& legendLayerFont() const = 0;
virtual const QFont& legendItemFont() const = 0;
virtual QFont legendLayerFont() const = 0;
virtual QFont legendItemFont() const = 0;

virtual double maxWidth() const = 0;
virtual double maxHeight() const = 0;
@@ -46,8 +46,8 @@ class QgsWmsProjectParser : public QgsWmsConfigParser
double legendIconLabelSpace() const /*override*/ ;
double legendSymbolWidth() const /*override*/ ;
double legendSymbolHeight() const /*override*/ ;
const QFont& legendLayerFont() const /*override*/ ;
const QFont& legendItemFont() const /*override*/ ;
QFont legendLayerFont() const /*override*/ ;
QFont legendItemFont() const /*override*/ ;

double maxWidth() const /*override*/ ;
double maxHeight() const /*override*/ ;
@@ -67,7 +67,7 @@ class ANALYSIS_EXPORT QgsInterpolator
virtual int interpolatePoint( double x, double y, double& result ) = 0;

//! @note not available in Python bindings
const QList<LayerData>& layerData() const { return mLayerData; }
QList<LayerData> layerData() const { return mLayerData; }

protected:

@@ -61,7 +61,7 @@ class ANALYSIS_EXPORT QgsRelief

void clearReliefColors();
void addReliefColorClass( const ReliefColor& color );
const QList< ReliefColor >& reliefColors() const { return mReliefColors; }
QList< ReliefColor > reliefColors() const { return mReliefColors; }
void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }

/** Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression
@@ -104,7 +104,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase

QAction* windowAction() {return mWindowAction;}

const QString& title() const {return mTitle;}
QString title() const {return mTitle;}
void setTitle( const QString& title );

/** Loads the contents of a template document into the composer's composition.
@@ -65,7 +65,7 @@ QgsMeasureTool::~QgsMeasureTool()
}


const QList<QgsPoint>& QgsMeasureTool::points()
QList<QgsPoint> QgsMeasureTool::points()
{
return mPoints;
}
@@ -52,7 +52,7 @@ class APP_EXPORT QgsMeasureTool : public QgsMapTool
void addPoint( const QgsPoint &point );

//! Returns reference to array of the points
const QList<QgsPoint>& points();
QList<QgsPoint> points();

// Inherited from QgsMapTool

@@ -246,7 +246,7 @@ QString QgsAuthMethodRegistry::pluginList( bool asHtml ) const
return list;
}

const QDir &QgsAuthMethodRegistry::libraryDirectory() const
QDir QgsAuthMethodRegistry::libraryDirectory() const
{
return mLibraryDirectory;
}
@@ -56,7 +56,7 @@ class CORE_EXPORT QgsAuthMethodRegistry
QString pluginList( bool asHtml = false ) const;

//! Return library directory where plugins are found
const QDir & libraryDirectory() const;
QDir libraryDirectory() const;

//! Set library directory where to search for plugins
void setLibraryDirectory( const QDir & path );
@@ -176,7 +176,7 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
* @see setPredefinedScales
* @see QgsComposerMap::atlasScalingMode
*/
const QVector<qreal>& predefinedScales() const { return mPredefinedScales; }
QVector<qreal> predefinedScales() const { return mPredefinedScales; }

/** Sets the list of predefined scales for the atlas. This is used
* for maps which are set to the predefined atlas scaling mode.
@@ -80,7 +80,7 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
* @see setUrl
* @see contentMode
*/
const QUrl& url() const { return mUrl; }
QUrl url() const { return mUrl; }

/** Sets the HTML to display in the item when the item is using
* the QgsComposerHtml::ManualHtml mode. Setting the HTML using this function
@@ -301,7 +301,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
double snapGridOffsetY() const {return mSnapGridOffsetY;}

void setGridPen( const QPen& p );
const QPen& gridPen() const {return mGridPen;}
QPen gridPen() const {return mGridPen;}

void setGridStyle( const GridStyle s );
GridStyle gridStyle() const {return mGridStyle;}
@@ -1109,14 +1109,9 @@ bool QgsLayerTreeModel::testFlag( QgsLayerTreeModel::Flag f ) const
return mFlags.testFlag( f );
}

const QIcon& QgsLayerTreeModel::iconGroup()
QIcon QgsLayerTreeModel::iconGroup()
{
static QIcon icon;

if ( icon.isNull() )
icon = QgsApplication::getThemeIcon( QStringLiteral( "/mActionFolder.svg" ) );

return icon;
return QgsApplication::getThemeIcon( QStringLiteral( "/mActionFolder.svg" ) );
}

QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::filterLegendNodes( const QList<QgsLayerTreeModelLegendNode*>& nodes )
@@ -255,7 +255,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
*/
void refreshScaleBasedLayers( const QModelIndex& index = QModelIndex() );

static const QIcon& iconGroup();
static QIcon iconGroup();

//! Filter nodes from QgsMapLayerLegend according to the current filtering rules
QList<QgsLayerTreeModelLegendNode*> filterLegendNodes( const QList<QgsLayerTreeModelLegendNode*>& nodes );
@@ -585,7 +585,7 @@ QgsWmsLegendNode::QgsWmsLegendNode( QgsLayerTreeLayer* nodeLayer, QObject* paren
{
}

const QImage& QgsWmsLegendNode::getLegendGraphic() const
QImage QgsWmsLegendNode::getLegendGraphic() const
{
if ( ! mValid && ! mFetcher )
{
@@ -334,7 +334,7 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode
private:

// Lazily initializes mImage
const QImage& getLegendGraphic() const;
QImage getLegendGraphic() const;

QImage renderMessage( const QString& msg ) const;

@@ -84,7 +84,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
//! Get list of children of the node. Children are owned by the parent
QList<QgsLayerTreeNode*> children() { return mChildren; }
//! Get list of children of the node. Children are owned by the parent
const QList<QgsLayerTreeNode*>& children() const { return mChildren; }
QList<QgsLayerTreeNode*> children() const { return mChildren; }

//! Return name of the node
//! @note added in 3.0

0 comments on commit 231f6af

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